// cheat sheet
Linux Commands Cheat Sheet
The Linux commands every backend and DevOps engineer should have at their fingertips — file operations, permissions, networking, process inspection, log triage, and disk management.
Quick Reference
- ›ls -lah, cd, cp -r, mv, rm -rf (carefully)
- ›chmod / chown / umask for permissions
- ›ss -tlnp, curl -v, dig, traceroute for networking
- ›ps aux, top, htop, lsof for processes
- ›tail -f, journalctl -fu <svc>, grep -E for logs
- ›df -h, du -sh *, lsblk for disks
Learning Path
Recommended order
- 1.Beginner
- 2.Intermediate
- 3.Advanced
Prerequisites
- •A Linux shell (WSL, macOS terminal, or a real Linux box)
Skills you will learn
- ✓File and permission management
- ✓Network debugging
- ✓Process inspection
- ✓Log triage
- ✓Disk and filesystem ops
Estimated time
Refer to it as needed — internalize over months.
File operations
ls -lah # long, human sizes, hidden
cp -r src/ dst/ # recursive copy
mv old new # move/rename
rm -rf build/ # recursive force delete
find . -name "*.log" -mtime +7 -delete # safe-ish cleanup
xargs -I{} cp {} backup/ < files.txtPermissions
chmod 644 file # rw- r-- r--
chmod +x script.sh
chmod -R u+rwX,g+rX,o-rwx dir
chown -R app:app /var/lib/app
umask 027 # default new files: rwxr-x---Networking
ss -tlnp # listening TCP w/ pid
ss -tan state established # established connections
curl -v https://api.acme.com/health
dig +short api.acme.com
traceroute api.acme.com
nc -vz host 5432 # port reachability
iptables -L -n -v # firewall rulesProcesses
ps aux | grep java
top # live
htop # nicer top
pidof java
kill -SIGTERM <pid>
lsof -i :8080 # who owns port 8080
lsof -p <pid> # files held by pid
strace -p <pid> -f -e trace=networkLogs
tail -f /var/log/app.log
journalctl -fu nginx
journalctl --since "10 min ago" -u orders
grep -E "ERROR|WARN" app.log | tail
awk '/ERROR/ {print $1, $2, $NF}' app.log
zgrep "request_id=abc" app.log.*.gzDisk management
df -h # filesystem usage
du -sh ./* # per-directory size
lsblk # block devices
ncdu /var # interactive du
mount | column -t
findmnt /dataCommon Mistakes
- !rm -rf with a variable that's unset (rm -rf $DIR/) — always set -u.
- !chmod 777 'to fix permissions' — never the right answer.
- !Editing /etc/sudoers with vi instead of visudo.
- !Running `kill -9` first — try SIGTERM, give 10s, then escalate.
Production Tips
- ★Alias `rm` to `rm -I` interactively; keep `rm -rf` for scripts.
- ★Use `set -euo pipefail` at the top of every shell script.
- ★Prefer `ss` over `netstat` (faster, kernel-backed).
- ★Use `journalctl --vacuum-time=7d` to cap log disk usage.
Further Reading
Frequently Asked Questions
How should I use this cheat sheet?
Skim once end-to-end, then keep it open in a pinned tab. Copy a snippet, adapt it to your project, and refer back when memory fails.
Is this cheat sheet up to date?
It's maintained against the latest stable releases in 2026 and revised when commands or APIs change meaningfully.
