// the cheat sheet

The Essential Linux Commands Cheat Sheet (Explained)

33 commands that do most of the work, each with a real example and what it actually does. Search it, filter by category, and keep it open in a tab.

The graphical desktop is fine for browsing, but anyone serious about Linux ends up at the terminal. It is faster, scriptable, works the same over SSH on a server with no screen, and gives you precise control that point-and-click never will. Learning a few dozen commands is the difference between fighting your system and actually running it. Nothing here is optional knowledge; these are the commands you will type every single day.

This is a searchable reference, not a tutorial you read front to back. Use your browser's find (Ctrl+F) to jump to the command you need. Each entry tells you what the command does, gives a real example you can run, and explains what that example actually does. Categories are grouped logically: Files, Viewing, System, Permissions, Network, and Text. Bookmark it and come back whenever you forget a flag.

lsFiles
Lists the contents of a directory.
ls -lahLong format, all files including hidden, human-readable sizes.
cdFiles
Changes your current working directory.
cd /var/logMoves into the system log directory; 'cd -' jumps back to the previous one.
pwdFiles
Prints the full path of the directory you are currently in.
pwdShows where you are, useful inside scripts and deep directory trees.
cpFiles
Copies files and directories.
cp -r /etc/nginx /etc/nginx.bakRecursively copies a whole directory to a backup.
mvFiles
Moves or renames files and directories.
mv report.txt reports/2024-report.txtMoves and renames in one step; same command handles both.
rmFiles
Removes files and directories permanently.
rm -rf /tmp/buildRecursively force-deletes a directory; there is no undo, so check the path twice.
mkdirFiles
Creates new directories.
mkdir -p projects/app/srcCreates the full nested path, making parent directories as needed.
touchFiles
Creates an empty file or updates a file's timestamp.
touch index.htmlMakes an empty index.html, or refreshes its modified time if it exists.
findFiles
Searches for files and directories by name, type, size, and more.
find /home -name '*.log' -mtime +7Finds .log files under /home that were modified more than 7 days ago.
lnFiles
Creates links between files, hard or symbolic.
ln -s /opt/app/bin/app /usr/local/bin/appCreates a symbolic link so you can run 'app' from anywhere in your PATH.
catViewing
Prints file contents to the screen or concatenates files.
cat /etc/hostnameDumps the entire file; best for short files.
lessViewing
Views file contents one screen at a time with scrolling and search.
less /var/log/syslogScroll with arrows, search with /pattern, quit with q.
headViewing
Shows the first lines of a file.
head -n 20 access.logPrints the first 20 lines instead of the default 10.
tailViewing
Shows the last lines of a file, and can follow new output live.
tail -f /var/log/nginx/error.logStreams new lines as they are written; great for watching logs.
grepViewing
Searches text for lines matching a pattern.
grep -ri 'error' /var/logRecursively, case-insensitively searches all logs for the word error.
psSystem
Displays information about running processes.
ps auxLists every process with user, PID, CPU, and memory usage.
topSystem
Shows a live, updating view of processes and resource usage.
topPress q to quit; try 'htop' if installed for a friendlier view.
killSystem
Sends a signal to a process, usually to terminate it.
kill -9 4827Force-kills the process with PID 4827 when a normal kill won't work.
dfSystem
Reports disk space usage of mounted filesystems.
df -hShows free and used space in human-readable units like G and M.
duSystem
Estimates disk space used by files and directories.
du -sh /var/*Summarizes the size of each item under /var to find space hogs.
freeSystem
Shows total, used, and free memory and swap.
free -hDisplays RAM and swap usage in human-readable units.
unameSystem
Prints system and kernel information.
uname -aShows kernel version, hostname, and architecture all at once.
systemctlSystem
Controls systemd services and the system state.
systemctl status sshdChecks whether the SSH service is running; use start, stop, restart, enable similarly.
chmodPermissions
Changes file permission bits.
chmod 755 deploy.shMakes a script readable and executable by all, writable only by the owner.
chownPermissions
Changes the owner and group of files.
chown -R www-data:www-data /var/wwwRecursively gives the web server user ownership of the web root.
sudoPermissions
Runs a command with superuser or another user's privileges.
sudo apt updateRuns the command as root; prompts for your password the first time.
pingNetwork
Tests reachability of a host and measures latency.
ping -c 4 8.8.8.8Sends exactly 4 packets, then stops, so it does not run forever.
curlNetwork
Transfers data to or from a URL from the command line.
curl -I https://example.comFetches only the HTTP response headers to check status and server.
sshNetwork
Opens a secure shell session on a remote machine.
ssh user@192.168.1.10Logs in to the remote host as 'user'; add -p for a custom port.
wgetNetwork
Downloads files from the web non-interactively.
wget https://example.com/file.tar.gzSaves the file to the current directory; good for scripts and resumable downloads.
nanoText
A simple terminal text editor for quick edits.
nano /etc/hostsEdit, then save with Ctrl+O and exit with Ctrl+X.
tarText
Creates and extracts archive files, often compressed.
tar -czvf backup.tar.gz /etcCreates a gzip-compressed archive of /etc; use -xzvf to extract it.
sortText
Sorts lines of text, alphabetically or numerically.
sort -nr sizes.txtSorts numerically in reverse, putting the largest values first.

$ five things that make the terminal faster

You do not need to memorize all of these at once. Pick the ten you will use most, run them on a real machine, and let muscle memory do the rest. The terminal rewards repetition: every command here becomes second nature faster than you expect. Keep this page bookmarked, and when you forget a flag, search instead of guessing.

Next: install Linux →