Linux & terminal commands cheatsheet.
Navigate, manage files, search, and inspect your system — the terminal commands worth knowing. Tap to copy.
pwdPrint the current working directoryls -laList all files with details and hidden onescd <dir>Change into a directorycd ..Go up one directorycd ~Go to your home directorytouch <file>Create an empty file or update its timestampmkdir <dir>Create a new directorycp <src> <dst>Copy a file or foldermv <src> <dst>Move or rename a file or folderrm <file>Delete a filerm -rf <dir>Delete a folder and everything in itcat <file>Print a file's contentsgrep "text" <file>Search for text inside a filegrep -r "text" .Search recursively through a folderfind . -name "*.js"Find files matching a patternhead -n 20 <file>Show the first 20 lines of a filetail -f <file>Follow a file as new lines are addedwc -l <file>Count the lines in a filechmod +x <file>Make a file executablesudo <command>Run a command as the superuserps auxList running processeskill <pid>Stop a process by its IDdf -hShow disk space in human-readable formdu -sh <dir>Show the total size of a folderman <command>Open the manual page for a commandThe terminal is just a conversation
The command line feels intimidating until you realise it follows a simple pattern: a command, then options, then what to act on. ls -la ~/projects is "list, with details and hidden files, the projects folder." Once you see that shape, the rest is vocabulary. These commands work in bash and zsh — the default shells on Linux and macOS — and in WSL on Windows, so what you learn here transfers across all three.
Getting around and managing files
Navigation comes first: pwd tells you where you are, ls shows what's around you, and cd moves you between folders (cd .. goes up, cd ~ goes home). For files, cp copies, mv moves or renames, mkdir makes folders and rm deletes. Reading files is just as quick — cat dumps a whole file, while less lets you scroll through a long one and tail -f follows a log live as new lines arrive, which is invaluable when debugging.
Search is the real productivity unlock
Two commands do an enormous amount of work. grep searches inside files for text — grep -r "TODO" . scans an entire project in a moment — and find locates files by name or pattern, like find . -name "*.log". Learning to combine them with pipes (passing one command's output into another with the | symbol) is where the terminal starts to feel genuinely powerful, letting you filter, count and transform data in a single line.
A word of caution
The terminal does exactly what you tell it, instantly and usually without a confirmation or an undo. rm -rf deletes a folder and everything inside it permanently — there's no Recycle Bin — so read the path twice before you run anything destructive, and be especially careful with commands run as sudo, which act with full system privileges. With that respect for the power involved, the command line becomes the fastest way to work. These pair naturally with the Git commands and, on a Mac, the Homebrew commands for installing tools.