topics/10-cheat-sheet

Cheat Sheet

Every essential command, one page. Bookmark it, or print it and pin it above your desk.

CommandWhat it does
pwdShow the folder you're currently in
ls / ls -laList files · detailed list incl. hidden ones
cd folder / cd .. / cd ~Enter folder · go up one level · go home
mkdir -p a/bCreate folder(s), parents included
rmdir folderRemove an empty folder
cp a b / cp -r dir dstCopy a file · copy a folder recursively
mv a bMove or rename files/folders
rm file / rm -r dirDelete a file · delete a folder (no trash!)
touch fileCreate an empty file (or update its timestamp)
cat file / less filePrint whole file · scroll through it (q quits)
head file / tail -f logFirst 10 lines · last 10 lines, live-following
CommandWhat it does
man lsFull manual page for a command
ls --helpQuick built-in summary
grep -i "error" fileFind text in a file, ignoring case
grep -r "todo" ~/codeSearch text in every file of a folder
find ~ -name "*.pdf"Find files by name pattern
which python3Where a command's program lives
historyYour recently typed commands

System info

CommandWhat it does
uname -r / uname -aKernel version · full system info
df -hFree disk space, human-readable
du -sh folderTotal size of a folder
free -hRAM usage
top / htopLive process list (q quits)
whoami / whoYour username · who's logged in
uptimeHow long since last reboot

Permissions & admin

CommandWhat it does
sudo cmdRun one command as root (asks your password)
sudo !!Re-run the previous command, but with sudo
chmod +x script.shMake a script executable
chmod 644 fileOwner: read+write · everyone else: read
chmod 600 keyOwner-only access (SSH keys, secrets)
chown alex fileChange a file's owner
Remember the permission math: r=4, w=2, x=1. So 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--.

Package managers compared

ManagerFamilyInstallRemoveUpdate everythingSearch
apt Debian · Ubuntu · Mint sudo apt install pkg sudo apt remove pkg sudo apt update && sudo apt upgrade apt search x
pacman Arch · Manjaro sudo pacman -S pkg sudo pacman -Rns pkg sudo pacman -Syu pacman -Ss x
dnf Fedora · RHEL sudo dnf install pkg sudo dnf remove pkg sudo dnf upgrade dnf search x
flatpak Universal flatpak install app flatpak uninstall app flatpak update flatpak search x
snap Universal (Ubuntu default) sudo snap install app sudo snap remove app sudo snap refresh snap find x

Where things live

PathWhat lives there
/home/youYour files & personal settings — your kingdom
/etcSystem-wide configuration files
/var/logSystem and app logs — first stop when debugging
/usr/binInstalled programs
/tmpTemporary files (cleared on reboot)
/rootRoot user's home — locked to you
/media / /mntWhere USB drives appear

Terminal superpowers

ShortcutMagic
TabAutocomplete commands, files and folders
/ Walk through your command history
Ctrl + CStop a running command
Ctrl + LClear the screen
Ctrl + RSearch your history interactively
Ctrl + Shift + C / VCopy / paste in most terminals
exitClose the shell
Keep this page nearby

You've seen the whole map now — the terminal will feel like home sooner than you think.