A quick reference for essential Linux commands. Covers file management, process control, networking, permissions, systemd, and disk usage.
File Management
| Command | Description |
|---|---|
| ls -la | List all files with details |
| cp -r src/ dest/ | Copy directory recursively |
| mv old new | Move or rename file/directory |
| rm -rf dir/ | Remove directory and contents |
| find . -name "*.log" | Find files by name pattern |
| find . -mtime -7 | Find files modified in last 7 days |
| mkdir -p a/b/c | Create nested directories |
| ln -s target link | Create symbolic link |
| tar -czf archive.tar.gz dir/ | Create gzipped tar archive |
| tar -xzf archive.tar.gz | Extract gzipped tar archive |
Process Control
| Command | Description |
|---|---|
| ps aux | List all running processes |
| top | Interactive process viewer |
| htop | Enhanced interactive process viewer |
| kill <pid> | Send SIGTERM to process |
| kill -9 <pid> | Force kill process (SIGKILL) |
| killall <name> | Kill all processes by name |
| bg / fg | Resume job in background / foreground |
| nohup cmd & | Run command immune to hangups |
| jobs | List background jobs |
Networking
| Command | Description |
|---|---|
| curl -O <url> | Download file from URL |
| curl -X POST -d @data.json <url> | Send POST request with data |
| wget <url> | Download file (with resume support) |
| ss -tulnp | Show listening ports with process info |
| ip addr | Show network interfaces and IPs |
| ping -c 4 host | Send 4 ICMP echo requests |
| dig example.com | DNS lookup |
| traceroute host | Trace packet route to host |
| netstat -tulnp | Show listening ports (legacy) |
Permissions
| Command | Description |
|---|---|
| chmod 755 file | rwxr-xr-x — owner full, others read/execute |
| chmod 644 file | rw-r--r-- — owner read/write, others read |
| chmod +x script.sh | Add execute permission |
| chmod -R 750 dir/ | Set permissions recursively |
| chown user:group file | Change file owner and group |
| chown -R user dir/ | Change ownership recursively |
| umask 022 | Set default permission mask |
| stat file | Show file permissions and metadata |
Systemd
| Command | Description |
|---|---|
| systemctl start <service> | Start a service |
| systemctl stop <service> | Stop a service |
| systemctl restart <service> | Restart a service |
| systemctl status <service> | Check service status |
| systemctl enable <service> | Enable service on boot |
| systemctl disable <service> | Disable service on boot |
| journalctl -u <service> -f | Follow service logs |
| systemctl list-units --type=service | List all loaded services |
Disk Usage
| Command | Description |
|---|---|
| df -h | Show disk space usage (human readable) |
| du -sh dir/ | Show directory size |
| du -h --max-depth=1 | Show size of immediate subdirectories |
| lsblk | List block devices |
| mount /dev/sda1 /mnt | Mount a filesystem |
| umount /mnt | Unmount a filesystem |
| fdisk -l | List disk partitions |
| ncdu | Interactive disk usage analyzer |
Text Processing
| Command | Description |
|---|---|
| grep -r "pattern" . | Search recursively in files |
| grep -i "pattern" file | Case-insensitive search |
| sed -i "s/old/new/g" file | Find and replace in file |
| awk '{print $1}' file | Print first column |
| sort file | uniq -c | Count unique lines |
| wc -l file | Count lines in file |
| head -n 20 file | Show first 20 lines |
| tail -f file | Follow file output in real time |