Linux Commands Cheat Sheet

Grouped by what you're actually doing — with the flags that matter, and the one that bites.

You don't need 400 commands. You need about fifty, and you need to know which flag turns each one from "prints something" into "does the thing you meant." Here they are by task.

Getting around

CommandWhat it does
pwdWhere am I
ls -lahList everything — long, all (incl. hidden), human-readable sizes. The only ls you need.
cd -Jump back to the previous directory. Underrated.
find . -name "*.log"Find files by name from here down
which / command -vWhere does this binary live

Files

CommandWhat it does
cp -r src/ dst/Copy a directory (recursive)
mv old newMove or rename — same command
mkdir -p a/b/cMake nested dirs, no error if they exist
ln -s target linkSymlink
rsync -av src/ dst/Better copy — resumable, shows progress, works over SSH
The one that bites: rm -rf has no undo and no confirmation. Before you run it, run the same path with ls first. A space in the wrong place (rm -rf / home/user) has ended careers.

Reading files and logs

CommandWhat it does
less filePage through. / to search, q to quit, G for end.
tail -f app.logFollow a log live. The command you'll use most in an outage.
tail -n 100 fileLast 100 lines
grep -ri "error" .Search recursively, case-insensitive
grep -C 3 "error" fileShow 3 lines of context around each hit — the flag that makes grep useful
journalctl -u nginx -fFollow a systemd service's logs

Permissions

CommandWhat it does
chmod 644 fileOwner read/write, everyone else read — normal file
chmod 755 dirOwner full, others read/execute — normal directory or script
chmod 600 ~/.ssh/id_rsaOwner only. SSH refuses keys that are more open than this.
chown user:group fileChange ownership

The numbers are just read=4, write=2, execute=1, added together, for owner/group/other. 7 = all three, 6 = read+write, 5 = read+execute.

Processes

CommandWhat it does
ps aux | grep nginxIs it running, and as what PID
topLive CPU/memory. htop if installed — much nicer.
kill PIDAsk a process to stop politely (SIGTERM)
kill -9 PIDForce it. Last resort — no cleanup, no saved state.
systemctl status|restart svcCheck or bounce a service

Disk and memory

CommandWhat it does
df -hFree space per filesystem. First thing to check when things break oddly.
du -sh *What's eating the space in this directory
free -hMemory in human units
lsblkDisks and partitions
Troubleshooting tell: when a server starts behaving strangely for no clear reason, run df -h first. A full disk breaks logging, databases, and sessions in ways that look like ten unrelated bugs.

Network

CommandWhat it does
ip aInterfaces and IP addresses (replaces ifconfig)
ss -tulpnWhat's listening on what port, and which process. Replaces netstat.
ping -c 4 hostBasic reachability
dig name +shortDNS lookup, just the answer
curl -I urlHeaders only — quick "is it up and what's it returning"
traceroute hostWhere the path dies

Archives

CommandWhat it does
tar -czf out.tar.gz dir/Create a gzipped archive
tar -xzf in.tar.gzExtract one

Remember it as create vs extract: -c creates, -x extracts, and -zf is the same on both.

Want this printable, on one page?

The Ultimate Linux Command Cheat Sheet — clean, printable, made to pin above the desk. Instant download.

Get the sheet — $3 →

Working in containers too? The Docker & Compose sheet covers the same ground for containers. And the ports reference pairs with ss -tulpn when you're figuring out what's listening.