Skip to main content

File System Hierarchy

DirectoryPurpose
/Root of the file system
/etcSystem configuration files
/varVariable data (logs, spool, temp)
/tmpTemporary files (world-writable)
/procVirtual FS — kernel & process info
/homeUser home directories
/rootRoot user’s home
/optOptional/third-party software
/usr/binUser binaries
/sbinSystem administration binaries

File Permissions

# Permission format: [type][owner][group][others]
# Example: -rwxr-xr-- = file, owner rwx, group r-x, others r--

# View permissions
ls -la

# Change permissions
chmod 755 file.sh       # rwxr-xr-x
chmod u+x file.sh       # add execute for owner
chmod o-r file.sh       # remove read for others

# Change ownership
chown root:root file
chown user:group file

Processes

# View running processes
ps aux
ps -ef

# Process tree
pstree -p

# Real-time monitoring
top
htop

# Kill a process
kill -9 <PID>
pkill processname

# Background/foreground jobs
command &        # run in background
jobs             # list background jobs
fg %1            # bring job 1 to foreground
bg %1            # send job 1 to background

Environment Variables

# View all env vars
env
printenv

# Set variable
export MY_VAR="value"

# Useful vars for offensive work
echo $PATH
echo $HOME
echo $USER
echo $SHELL

Essential Commands

# Find files
find / -name "flag.txt" 2>/dev/null
find / -user root -perm -4000 2>/dev/null    # SUID files

# Search within files
grep -r "password" /etc/ 2>/dev/null
grep -ri "secret" /var/www/html/

# File content
cat /etc/passwd
less /var/log/auth.log
head -20 file.txt
tail -f /var/log/syslog    # live follow

# Archive and transfer
tar -czf archive.tar.gz /path/to/dir
tar -xzf archive.tar.gz

# Network
ss -tulnp           # open ports
netstat -tulnp      # same (older)
curl http://target.com
wget http://target.com/file