// Cheat SheetQuick Reference
Linux Command Cheat Sheet
A running reference of the Linux commands I find myself using or looking up most often — organized by category. Covers everyday file navigation, text processing, user and permission management, and networking. Commands are written for a typical Bash environment on Debian/Ubuntu or RHEL/Rocky; most will work on any modern Linux distro.
//Navigation & Files22 commands
CommandWhat it does
pwdPrint the full path of the current working directorylsList files and directories in the current directoryls -laList all files (including hidden) with detailed infocd <dir>Change into a directorycd ..Move up one directory levelcd ~Go to your home directorymkdir <dir>Create a new directorymkdir -p <path>Create a directory and any missing parent directoriestouch <file>Create an empty file, or update its timestamp if it existscp <src> <dest>Copy a file from source to destinationcp -r <src> <dest>Copy a directory and all its contents recursivelymv <src> <dest>Move or rename a file or directoryrm <file>Delete a file permanentlyrm -rf <dir>Delete a directory and everything in it — no confirmationfind <path> -name <pattern>Search for files matching a name patternfind . -type f -mtime -7Find files modified in the last 7 dayslocate <name>Fast file search using an indexed databaseln -s <target> <link>Create a symbolic (soft) link to a file or directorystat <file>Show detailed metadata about a filedu -sh <dir>Show total disk usage of a directory in human-readable formdf -hShow available disk space on all mounted filesystemstreeDisplay directory structure as a visual tree
//Text & Search22 commands
CommandWhat it does
cat <file>Print the contents of a file to the terminalless <file>View a file page by page — press q to quithead -n <N> <file>Show the first N lines of a filetail -n <N> <file>Show the last N lines of a filetail -f <file>Stream a file as it grows — ideal for watching logsgrep <pattern> <file>Search for lines matching a pattern in a filegrep -r <pattern> <dir>Search for a pattern recursively across all files in a directorygrep -i <pattern>Case-insensitive pattern searchgrep -v <pattern>Show lines that do NOT match the patternsed 's/old/new/g' <file>Replace every occurrence of old with new in a file (output only)sed -i 's/old/new/g' <file>Replace text inside a file in placeawk '{print $1}' <file>Print the first field (column) of each linecut -d: -f1 <file>Extract the first field using : as the delimitersort <file>Sort lines in a file alphabeticallysort -n <file>Sort lines numericallyuniqRemove consecutive duplicate lines (pipe from sort first)sort | uniq -cSort and count how many times each unique line appearswc -l <file>Count the number of lines in a filewc -w <file>Count the number of words in a filediff <file1> <file2>Show line-by-line differences between two filesecho <text>Print text to the terminal or redirect it into a filetee <file>Write stdin to both stdout and a file simultaneously
//Permissions & Users22 commands
CommandWhat it does
whoamiPrint the name of the currently logged-in useridShow your user ID, primary group ID, and all group membershipsgroupsList all groups the current user belongs tosudo <command>Run a command with superuser (root) privilegessudo -iOpen an interactive root shellsu - <user>Switch to another user accountchmod 755 <file>Set rwxr-xr-x permissions — owner can write, others can read and executechmod +x <file>Make a file executablechmod -R 644 <dir>Apply permissions recursively to all files in a directorychown <user> <file>Change the owner of a filechown <user>:<group> <file>Change both the owner and group of a filechown -R <user>:<group> <dir>Change owner and group recursivelyuseradd -m <user>Create a new user with a home directoryuserdel -r <user>Delete a user and remove their home directoryusermod -aG <group> <user>Add a user to a group without removing existing groupspasswd <user>Set or change a user passwordgroupadd <group>Create a new groupvisudoSafely edit the sudoers file with syntax validationlastShow recent login history for all usersumask 022Set the default permissions mask for newly created filesls -l <file>View the permission string, owner, and group of a filestat <file>Show full permission details including octal notation
//Networking22 commands
CommandWhat it does
ip addr showShow all network interfaces and their IP addressesip route showDisplay the routing tableip link set <iface> upBring a network interface upping <host>Test basic network connectivity to a hostping -c 4 <host>Send exactly 4 ping packets then stoptraceroute <host>Show the route packets take to reach a hostss -tulnpShow all listening TCP/UDP ports and the process using eachss -sShow a summary of socket statisticscurl <url>Fetch content from a URLcurl -I <url>Fetch only the HTTP response headers from a URLcurl -O <url>Download a file, preserving the remote filenamewget <url>Download a file from a URLwget -r <url>Recursively download an entire websitessh <user>@<host>Open a secure shell session on a remote hostssh -i <key> <user>@<host>Connect to a remote host using a private key filescp <file> <user>@<host>:<path>Securely copy a file to a remote hostscp -r <dir> <user>@<host>:<path>Securely copy a directory to a remote hostdig <domain>Perform a full DNS lookup for a domaindig +short <domain>Quick DNS lookup — returns only the answernslookup <domain>Query a DNS server interactivelynmap -sV <host>Scan a host and detect service versions on open portsufw statusShow the current firewall rules and status
// Download a copy
This is a personal reference, not a comprehensive manual. If you spot an error or a command that should be here, reach out via the contact page.