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.
lsFilesls -lahLong format, all files including hidden, human-readable sizes.cdFilescd /var/logMoves into the system log directory; 'cd -' jumps back to the previous one.pwdFilespwdShows where you are, useful inside scripts and deep directory trees.cpFilescp -r /etc/nginx /etc/nginx.bakRecursively copies a whole directory to a backup.mvFilesmv report.txt reports/2024-report.txtMoves and renames in one step; same command handles both.rmFilesrm -rf /tmp/buildRecursively force-deletes a directory; there is no undo, so check the path twice.mkdirFilesmkdir -p projects/app/srcCreates the full nested path, making parent directories as needed.touchFilestouch index.htmlMakes an empty index.html, or refreshes its modified time if it exists.findFilesfind /home -name '*.log' -mtime +7Finds .log files under /home that were modified more than 7 days ago.lnFilesln -s /opt/app/bin/app /usr/local/bin/appCreates a symbolic link so you can run 'app' from anywhere in your PATH.catViewingcat /etc/hostnameDumps the entire file; best for short files.lessViewingless /var/log/syslogScroll with arrows, search with /pattern, quit with q.headViewinghead -n 20 access.logPrints the first 20 lines instead of the default 10.tailViewingtail -f /var/log/nginx/error.logStreams new lines as they are written; great for watching logs.grepViewinggrep -ri 'error' /var/logRecursively, case-insensitively searches all logs for the word error.psSystemps auxLists every process with user, PID, CPU, and memory usage.topSystemtopPress q to quit; try 'htop' if installed for a friendlier view.killSystemkill -9 4827Force-kills the process with PID 4827 when a normal kill won't work.dfSystemdf -hShows free and used space in human-readable units like G and M.duSystemdu -sh /var/*Summarizes the size of each item under /var to find space hogs.freeSystemfree -hDisplays RAM and swap usage in human-readable units.unameSystemuname -aShows kernel version, hostname, and architecture all at once.systemctlSystemsystemctl status sshdChecks whether the SSH service is running; use start, stop, restart, enable similarly.chmodPermissionschmod 755 deploy.shMakes a script readable and executable by all, writable only by the owner.chownPermissionschown -R www-data:www-data /var/wwwRecursively gives the web server user ownership of the web root.sudoPermissionssudo apt updateRuns the command as root; prompts for your password the first time.pingNetworkping -c 4 8.8.8.8Sends exactly 4 packets, then stops, so it does not run forever.curlNetworkcurl -I https://example.comFetches only the HTTP response headers to check status and server.sshNetworkssh user@192.168.1.10Logs in to the remote host as 'user'; add -p for a custom port.wgetNetworkwget https://example.com/file.tar.gzSaves the file to the current directory; good for scripts and resumable downloads.nanoTextnano /etc/hostsEdit, then save with Ctrl+O and exit with Ctrl+X.tarTexttar -czvf backup.tar.gz /etcCreates a gzip-compressed archive of /etc; use -xzvf to extract it.sortTextsort -nr sizes.txtSorts numerically in reverse, putting the largest values first.No commands match. Try a different word.
$ five things that make the terminal faster
- Press Tab to auto-complete file names and commands; press it twice to list all matches.
- Use the Up and Down arrows to scroll through previous commands, or run 'history' to see them all.
- Pipe output between commands with |, like 'ps aux | grep nginx', to filter and combine tools.
- Stuck on a command? Read its manual with 'man command' and quit with q.
- Press Ctrl+C to cancel a running command, and Ctrl+L to clear the screen instantly.
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.