Quick Reference

Cheat Sheets

Command tables for the tools you use daily. Copy, paste, bookmark, print.

Linux Essentials // file & directory
CommandWhat it does
ls -lahList all files with sizes, hidden included
pwdPrint current working directory
cd /pathChange to absolute path
cd ~Go to home directory
mkdir -p dir/subCreate nested directories at once
rm -rf dir/Delete directory and all contents — no prompt
cp -r src/ dst/Copy directory recursively
mv old newMove or rename file/directory
find / -name "*.conf"Find files by name from root
chmod 755 filerwxr-xr-x — owner write, others execute
chown user:group fileChange file ownership
ln -s target linkCreate a symbolic link
Linux Essentials // processes & system
CommandWhat it does
ps auxList all running processes
top / htopLive process monitor (htop is friendlier)
kill -9 PIDForce-kill a process by PID
pkill nginxKill all processes matching name
systemctl status svcCheck service status
systemctl restart svcRestart a systemd service
systemctl enable svcStart service automatically on boot
journalctl -u nginx -fFollow live logs for a service
df -hDisk usage by mount point, human-readable
du -sh dir/Total size of a directory
free -hMemory usage summary
uptimeHow long the system has been running
uname -aKernel version and architecture
whoamiCurrent user
sudo !! Re-run last command with sudo
Tip: Pipe ps aux into grep nginx to filter — ps aux | grep nginx
Linux Essentials // text & search
CommandWhat it does
cat filePrint file contents to terminal
less filePage through file (q to quit)
tail -n 50 fileShow last 50 lines
tail -f fileFollow file as it grows (logs)
grep -r "term" dir/Search recursively for term in directory
grep -i "term" fileCase-insensitive search
sed -i 's/old/new/g' fFind and replace in file (in-place)
awk '{print }' filePrint first column of each line
wc -l fileCount lines in file
sort file | uniq -cCount unique lines
diff file1 file2Show differences between two files
SSH // connecting & keys
CommandWhat it does
ssh user@hostConnect to remote host as user
ssh -p 2222 user@hostConnect on non-default port
ssh -i ~/.ssh/key user@hostUse specific private key
ssh-keygen -t ed25519Generate modern Ed25519 keypair
ssh-copy-id user@hostPush your public key to remote authorized_keys
ssh-keygen -R hostRemove stale host fingerprint
cat ~/.ssh/id_ed25519.pubPrint your public key to copy
chmod 700 ~/.sshFix 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
CommandWhat it does
ssh -L 8080:localhost:80 user@hostForward remote port 80 to local 8080
ssh -R 9090:localhost:3000 user@hostExpose local port 3000 to remote 9090
ssh -D 1080 user@hostSOCKS5 proxy through SSH
ssh -N -f user@host ...Background tunnel, no shell
ssh -v user@hostVerbose — debug connection issues
~/.ssh/config example:

Host myserver
  HostName 203.0.113.10
  User ubuntu
  IdentityFile ~/.ssh/id_ed25519
  Port 22


Then just: ssh myserver
Networking // diagnostics
CommandWhat it does
ip aShow all interfaces and IP addresses
ip rShow routing table
ping -c 4 hostSend 4 ICMP packets to host
traceroute hostTrace packet path to destination
nslookup domainQuery DNS for a domain
dig domainDetailed DNS lookup
dig +short domainJust the IP answer
curl -I https://siteFetch HTTP headers only
wget -O- urlFetch URL contents to stdout
ss -tulnpShow listening ports and which process owns them
netstat -tulnpSame as ss — older systems
tcpdump -i eth0 port 80Capture HTTP traffic on eth0
nmap -sV hostScan host for open ports and service versions
Security // ufw & hardening
CommandWhat it does
ufw status verboseShow firewall status and all rules
ufw default deny incomingBlock all inbound by default
ufw default allow outgoingAllow all outbound by default
ufw allow 22/tcpAllow SSH
ufw allow 80,443/tcpAllow HTTP and HTTPS
ufw deny from IPBlock specific IP address
ufw enableEnable firewall (rules take effect)
ufw delete allow 80/tcpRemove a rule
fail2ban-client statusCheck fail2ban jail status
lastShow recent login history
lastbShow failed login attempts
passwdChange current user password
chage -l userShow 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
CommandWhat it does
certbot --nginx -d domain.comIssue and install Let's Encrypt cert for Nginx
certbot renew --dry-runTest renewal without actually renewing
certbot certificatesList all managed certs and expiry dates
openssl s_client -connect host:443Inspect TLS handshake details
openssl x509 -in cert.pem -textRead certificate details from a PEM file