| Command | Description |
| • | apropos whatis | Show commands pertinent to string. You may need to first run: sudo mandb |
| • | man -t ascii | ps2pdf → ascii.pdf | Make a PDF of a manual page |
| | which command | Show full path name of command |
| | time command | See how long a command takes |
| • | time cat | Start stopwatch. Ctrl‑d to stop. See also sw |
| Dir Navigation |
| • | cd – | Go to previous directory |
| • | cd | Go to $HOME directory |
| | (cd dir && command) | Go to dir, run command then return |
| • | pushd . | Push current dir on stack; return via popd |
| File Searching |
| • | alias l='ls -l --color=auto' | Quick dir listing. (See also ls_color) |
| • | ls -lrt | List files by date (newest last). |
| • | ls /usr/bin | pr -T9 -W$COLUMNS | Print in 9 columns |
| | find -name '*.[ch]' | xargs grep -E 'expr' | Search files for expr() |
| | find … | xargs grep -F 'example' | Search for text in files |
| | find –maxdepth 1 … | Search in current dir only |
| • | find -type f ! -perm -444 | Find unreadable files |
| • | find -type d ! -perm -111 | Find inaccessible dirs |
| • | locate -r 'file[^/]*\.txt' | Cached search for names |
| • | look reference | Search prefix in dictionary |
| • | grep --color reference /usr/share/dict/words | Highlight regex matches |
| File Comparison |
| • | diff -u old.c new.c | Unified diff |
| • | diff -r dir1 dir2 | Recursively compare two directories |
| | comm -options file1 file2 | Compare sorted files |
| • | cmp file1 file2 | Show first difference between two binary files |
| | md5sum file | Print MD5 checksum for file |
| File Viewing |
| • | cat -n file | Show file with line numbers |
| • | less file | View file one page at a time |
| | head -n 20 file | Show first 20 lines |
| | tail -n 20 file | Show last 20 lines |
| • | tail -f file | Follow file as it grows |
| Disk Usage |
| • | df -h | Human-readable free space on mounted filesystems |
| • | du -sh * | Summarize disk usage for files and directories |
| | du -sh .[!.]* * | Include hidden files and directories |
| • | ncdu | Interactive disk usage viewer |
| Permissions |
| • | chmod 755 file | Set rwxr-xr-x permissions |
| | chmod -R o-r * | Remove read permission for others recursively |
| | chown user:group file | Change owner and group |
| | umask 022 | Set default permissions: rwxr-xr-x |
| Archiving & Compression |
| • | tar czf file.tar.gz files | Create gzip-compressed archive |
| • | tar xzf file.tar.gz | Extract gzip-compressed archive |
| | gzip -d file.gz | Decompress gzip file |
| • | zip -r file.zip dir | Create zip archive |
| | unzip file.zip | Extract zip archive |
| Networking |
| • | ping host | Test network connection |
| • | wget url | Download file from URL |
| • | curl -O url | Download file with curl |
| | scp file user@host:/path | Secure copy to remote host |
| | rsync -av file user@host:/path | Efficient file transfer |
| Process Management |
| • | top | Interactive process viewer |
| • | ps aux | Show all running processes |
| | kill pid | Send SIGTERM to process |
| • | kill -9 pid | Force kill a process |
| • | pkill name | Kill process by name |
| Miscellaneous |
| • | alias ll='ls -lh' | Create a shortcut command |
| | history | grep command | Search command history |
| • | !! | Repeat last command |
| | !abc | Repeat last command starting with abc |
| Git Commands |
| • | git init | Initialize new repository |
| • | git clone URL | Clone remote repository |
| • | git status | Show changed files |
| • | git add file | Stage file for commit |
| • | git commit -m "msg" | Commit changes |
| • | git log | Show commit history |
| • | git diff | Show changes not staged |
| • | git branch | List local branches |
| • | git checkout branch | Switch to branch |
| • | git merge branch | Merge branch into current |
| • | git pull | Update from remote |
| • | git push | Send commits to remote |
| systemd Commands |
| • | systemctl status | Show system status |
| • | systemctl status name | Status of a specific service |
| • | systemctl start name | Start a service |
| • | systemctl stop name | Stop a service |
| • | systemctl restart name | Restart a service |
| • | systemctl enable name | Enable service at boot |
| • | systemctl disable name | Disable service at boot |
| • | journalctl -xe | View recent system logs |
| • | systemctl list-units --type=service | List active services |
| Docker Commands |
| • | docker ps | List running containers |
| • | docker ps -a | List all containers |
| • | docker images | List images |
| • | docker pull image | Download image |
| • | docker run -it image | Run container interactively |
| • | docker exec -it name bash | Run bash inside container |
| • | docker stop name | Stop container |
| • | docker rm name | Remove container |
| • | docker rmi image | Remove image |
| • | docker-compose up | Start containers from compose file |
| • | docker-compose down | Stop and remove containers |
| SSH Commands |
| • | ssh user@host | Connect to host |
| • | ssh -i key.pem user@host | Use private key to connect |
| • | ssh-copy-id user@host | Copy public key to remote |
| • | scp file user@host:/path | Copy file to remote |
| • | scp user@host:/file . | Copy file from remote |
| • | rsync -avz src/ user@host:/dest | Efficient directory sync |
| tmux Commands |
| • | tmux | Start new session |
| • | tmux ls | List sessions |
| • | tmux attach -t name | Attach to session |
| • | tmux new -s name | New named session |
| • | Ctrl-b d | Detach session |
| • | Ctrl-b c | New window |
| • | Ctrl-b n / p | Next/previous window |
| • | Ctrl-b " | Split horizontal |
| • | Ctrl-b % | Split vertical |
| • | Ctrl-b x | Close pane |
| sed & awk |
| • | sed 's/foo/bar/' file | Replace first "foo" with "bar" |
| • | sed -i 's/foo/bar/g' file | Replace all and edit in-place |
| • | sed -n '5,10p' file | Print lines 5 to 10 |
| • | awk '{print $1}' file | Print first column |
| • | awk -F ':' '{print $1}' file | Split by colon, print first field |
| • | awk '/pattern/ {print $0}' file | Print lines matching pattern |
| System Info |
| • | uname -a | Kernel and architecture |
| • | hostnamectl | Show hostname and OS info |
| • | uptime | Show system uptime |
| • | whoami | Current user |
| • | id | User ID and groups |
| • | top / htop | Running processes |
| • | df -h | Disk usage |
| • | free -h | Memory usage |
| • | lsblk | List block devices |
| • | lscpu / lsusb / lspci | CPU / USB / PCI info |