Linux Commands

Linux & terminal commands cheatsheet.

Navigate, manage files, search, and inspect your system — the terminal commands worth knowing. Tap to copy.

Navigating
pwdPrint the current working directory
ls -laList all files with details and hidden ones
cd <dir>Change into a directory
cd ..Go up one directory
cd ~Go to your home directory
Files & folders
touch <file>Create an empty file or update its timestamp
mkdir <dir>Create a new directory
cp <src> <dst>Copy a file or folder
mv <src> <dst>Move or rename a file or folder
rm <file>Delete a file
rm -rf <dir>Delete a folder and everything in it
cat <file>Print a file's contents
Search & text
grep "text" <file>Search for text inside a file
grep -r "text" .Search recursively through a folder
find . -name "*.js"Find files matching a pattern
head -n 20 <file>Show the first 20 lines of a file
tail -f <file>Follow a file as new lines are added
wc -l <file>Count the lines in a file
System & permissions
chmod +x <file>Make a file executable
sudo <command>Run a command as the superuser
ps auxList running processes
kill <pid>Stop a process by its ID
df -hShow disk space in human-readable form
du -sh <dir>Show the total size of a folder
man <command>Open the manual page for a command

The 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.

FAQ

How do I search for text inside files in the terminal?
Use grep "text" <file> for one file, or grep -r "text" . to search every file under the current folder recursively.
What does rm -rf do?
It removes a folder and everything inside it, recursively and without prompting. There's no undo, so double-check the path before running it.

More cheatsheets