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, demystified

These commands work in bash and zsh on Linux and macOS (and WSL on Windows). The essentials — ls, cd, cp, mv, rm — get you around, while grep and find are the search workhorses. Be careful with rm -rf: it deletes permanently with no recycle bin.

FAQ

How do I search for text inside files in the terminal?
Use grep "text" 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