Quick Reference
Cheat Sheets
Command tables for the tools you use daily. Copy, paste, bookmark, print.
Linux Essentials // file & directory
| Command | What it does |
|---|---|
| ls -lah | List all files with sizes, hidden included |
| pwd | Print current working directory |
| cd /path | Change to absolute path |
| cd ~ | Go to home directory |
| mkdir -p dir/sub | Create nested directories at once |
| rm -rf dir/ | Delete directory and all contents — no prompt |
| cp -r src/ dst/ | Copy directory recursively |
| mv old new | Move or rename file/directory |
| find / -name "*.conf" | Find files by name from root |
| chmod 755 file | rwxr-xr-x — owner write, others execute |
| chown user:group file | Change file ownership |
| ln -s target link | Create a symbolic link |
Linux Essentials // processes & system
| Command | What it does |
|---|---|
| ps aux | List all running processes |
| top / htop | Live process monitor (htop is friendlier) |
| kill -9 PID | Force-kill a process by PID |
| pkill nginx | Kill all processes matching name |
| systemctl status svc | Check service status |
| systemctl restart svc | Restart a systemd service |
| systemctl enable svc | Start service automatically on boot |
| journalctl -u nginx -f | Follow live logs for a service |
| df -h | Disk usage by mount point, human-readable |
| du -sh dir/ | Total size of a directory |
| free -h | Memory usage summary |
| uptime | How long the system has been running |
| uname -a | Kernel version and architecture |
| whoami | Current user |
| sudo !! | Re-run last command with sudo |
Tip: Pipe
ps aux into grep nginx to filter — ps aux | grep nginxLinux Essentials // text & search
| Command | What it does |
|---|---|
| cat file | Print file contents to terminal |
| less file | Page through file (q to quit) |
| tail -n 50 file | Show last 50 lines |
| tail -f file | Follow file as it grows (logs) |
| grep -r "term" dir/ | Search recursively for term in directory |
| grep -i "term" file | Case-insensitive search |
| sed -i 's/old/new/g' f | Find and replace in file (in-place) |
| awk '{print }' file | Print first column of each line |
| wc -l file | Count lines in file |
| sort file | uniq -c | Count unique lines |
| diff file1 file2 | Show differences between two files |
SSH // connecting & keys
| Command | What it does |
|---|---|
| ssh user@host | Connect to remote host as user |
| ssh -p 2222 user@host | Connect on non-default port |
| ssh -i ~/.ssh/key user@host | Use specific private key |
| ssh-keygen -t ed25519 | Generate modern Ed25519 keypair |
| ssh-copy-id user@host | Push your public key to remote authorized_keys |
| ssh-keygen -R host | Remove stale host fingerprint |
| cat ~/.ssh/id_ed25519.pub | Print your public key to copy |
| chmod 700 ~/.ssh | Fix SSH directory permissions |
| chmod 600 ~/.ssh/id_* | Fix private key permissions |
Prefer Ed25519 over RSA — shorter keys, faster, more secure. Use
-t ed25519 when generating.SSH // tunnels & config
| Command | What it does |
|---|---|
| ssh -L 8080:localhost:80 user@host | Forward remote port 80 to local 8080 |
| ssh -R 9090:localhost:3000 user@host | Expose local port 3000 to remote 9090 |
| ssh -D 1080 user@host | SOCKS5 proxy through SSH |
| ssh -N -f user@host ... | Background tunnel, no shell |
| ssh -v user@host | Verbose — debug connection issues |
~/.ssh/config example:
Then just:
Host myserver
HostName 203.0.113.10
User ubuntu
IdentityFile ~/.ssh/id_ed25519
Port 22Then just:
ssh myserverNetworking // diagnostics
| Command | What it does |
|---|---|
| ip a | Show all interfaces and IP addresses |
| ip r | Show routing table |
| ping -c 4 host | Send 4 ICMP packets to host |
| traceroute host | Trace packet path to destination |
| nslookup domain | Query DNS for a domain |
| dig domain | Detailed DNS lookup |
| dig +short domain | Just the IP answer |
| curl -I https://site | Fetch HTTP headers only |
| wget -O- url | Fetch URL contents to stdout |
| ss -tulnp | Show listening ports and which process owns them |
| netstat -tulnp | Same as ss — older systems |
| tcpdump -i eth0 port 80 | Capture HTTP traffic on eth0 |
| nmap -sV host | Scan host for open ports and service versions |
Security // ufw & hardening
| Command | What it does |
|---|---|
| ufw status verbose | Show firewall status and all rules |
| ufw default deny incoming | Block all inbound by default |
| ufw default allow outgoing | Allow all outbound by default |
| ufw allow 22/tcp | Allow SSH |
| ufw allow 80,443/tcp | Allow HTTP and HTTPS |
| ufw deny from IP | Block specific IP address |
| ufw enable | Enable firewall (rules take effect) |
| ufw delete allow 80/tcp | Remove a rule |
| fail2ban-client status | Check fail2ban jail status |
| last | Show recent login history |
| lastb | Show failed login attempts |
| passwd | Change current user password |
| chage -l user | Show password expiry for user |
Hardening order: default deny → allow only what you need → enable fail2ban → disable password auth in sshd_config → reboot and verify.
Security // certbot & ssl
| Command | What it does |
|---|---|
| certbot --nginx -d domain.com | Issue and install Let's Encrypt cert for Nginx |
| certbot renew --dry-run | Test renewal without actually renewing |
| certbot certificates | List all managed certs and expiry dates |
| openssl s_client -connect host:443 | Inspect TLS handshake details |
| openssl x509 -in cert.pem -text | Read certificate details from a PEM file |