Welcome to the ultimate Linux commands cheat sheet, designed for beginners and seasoned sysadmins alike. This comprehensive guide covers 100 of the most essential Linux commands, organized by category, with clear descriptions, practical examples, and tips for chaining commands to streamline your workflows. Whether you’re managing files, monitoring systems, or scripting automation, this cheat sheet from SquidHacker  is your go-to resource for mastering the Linux terminal.
File and Directory Management  
Commands for creating, moving, copying, and deleting files and directories, plus tools for searching and archiving. 
 
 
Text Processing  
Tools for viewing, editing, searching, and manipulating text files, ideal for log analysis and data parsing. 
 
 
System Information  
Commands to monitor system resources, check hardware details, and track running processes. 
 
 
Network  
Utilities for managing network connections, testing connectivity, and transferring files securely. 
 
 
User and Permission Management  
Commands to create, modify, and delete user accounts, as well as manage file permissions. 
 
 
Package Management  
Tools for installing, updating, and managing software packages across different Linux distributions. 
 
 
Process Management  
Commands to monitor, prioritize, and terminate processes for efficient system performance. 
 
 
Disk and Filesystem  
Utilities for managing disks, partitions, and filesystems, including mounting and formatting. 
 
 
Shell and Scripting  
Commands for scripting, environment management, and creating shortcuts to streamline workflows. 
 
 
Other Utilities  
Miscellaneous tools for accessing manuals, clearing the terminal, and monitoring changes. 
 
 
 
Introduction to Command Chaining 
Chaining commands in Linux is a powerful way to combine multiple operations for efficient, automated workflows. By linking commands, you can process data, handle errors, and execute complex tasks in a single line. Here are the key methods:
Piping (|) : Passes the output of one command as input to another.Example : ls -l | grep "txt" lists files and filters those containing “txt”. 
Redirection (>, >>, <) : Redirects input/output to/from files.
>: Overwrites a file with output. Example : echo "Hello" > hello.txt. 
>>: Appends output to a file. Example : echo "World" >> hello.txt. 
<: Reads input from a file. Example : sort < unsorted.txt. 
 
 
Logical Operators (&&, ||) :
&&: Runs the second command if the first succeeds. Example : mkdir newdir && cd newdir. 
||: Runs the second command if the first fails. Example : ping -c 1 google.com || echo "No internet". 
 
 
 
Commands by Category 
1. File and Directory Management 
Command Description Purpose Basic Example Chaining Example lsLists directory contents View files and folders ls -lls -l | grep "txt" (filters files by pattern)cdChanges current directory Navigate filesystem cd /home/usercd /tmp && touch temp.txt (changes directory and creates file)pwdPrints working directory Confirm current location pwdpwd | xargs echo "Current dir:" (displays with prefix)mkdirCreates new directory Organize files mkdir newfoldermkdir logs && cd logs (creates and enters directory)rmdirRemoves empty directory Clean up unused folders rmdir oldfolderrmdir oldfolder || echo "Directory not empty" (handles errors)touchCreates empty file or updates timestamp Initialize files touch file.txttouch file.txt && echo "Data" > file.txt (creates and writes to file)cpCopies files/directories Duplicate data cp file.txt copy.txtcp file.txt backup/ | xargs ls (copies and lists)mvMoves/renames files Relocate or rename mv file.txt newfile.txtmv file.txt /tmp && ls /tmp (moves and verifies)rmDeletes files/directories Remove unwanted data rm -r folderrm file.txt || echo "File not found" (handles errors)findSearches for files Locate specific files find /home -name "*.txt"find . -type f -exec grep "error" {} \; (searches text in files)locateFinds files using database Quick file search locate document.pdflocate *.pdf | xargs ls (lists found PDFs)duEstimates file space usage Check disk usage du -sh folderdu -sh * | sort -h (sorts directories by size)dfReports disk space usage Monitor free space df -hdf -h | grep "/dev/sda" (filters specific disk)tarArchives files Bundle files tar -cvf archive.tar foldertar -cvf archive.tar folder | xargs ls -l (archives and lists)gzipCompresses files Reduce file size gzip file.txtgzip file.txt && ls *.gz (compresses and lists)gunzipDecompresses files Restore compressed files gunzip file.txt.gzgunzip file.txt.gz && cat file.txt (decompresses and displays)zipCompresses files into zip Create zip archives zip archive.zip file.txtzip archive.zip *.txt | xargs ls (zips and lists)unzipExtracts zip files Access zipped content unzip archive.zipunzip archive.zip && ls (extracts and lists)lnCreates links Share files via links ln -s file.txt linkln -s file.txt link && ls -l (creates link and verifies)fileDetermines file type Identify file formats file document.pdffile * | grep "PDF" (filters PDF files)
 
2. Text Processing 
Command Description Purpose Basic Example Chaining Example catDisplays file contents View or concatenate files cat file.txtcat file.txt | grep "error" (filters lines)lessViews file content page-wise Read large files less log.txtless log.txt | grep "error" (searches while viewing)moreDisplays file content page-wise Similar to less more log.txtmore log.txt | head -n 10 (shows first 10 lines)headShows first lines of file Preview file start head -n 5 file.txthead file.txt | grep "start" (filters first lines)tailShows last lines of file Monitor file end tail -n 5 file.txttail -f log.txt | grep "error" (monitors errors)grepSearches text patterns Find specific text grep "error" log.txtps aux | grep "process_name" (finds processes)sedStream editor for text Modify text sed 's/old/new/' file.txtcat file.txt | sed 's/error/warning/' (replaces text)awkProcesses text patterns Extract data awk '{print $1}' file.txtps aux | awk '{print $2}' (lists PIDs)sortSorts lines Organize data sort file.txtcat file.txt | sort -u (sorts uniquely)uniqFilters repeated lines Remove duplicates uniq file.txtsort file.txt | uniq (removes duplicates)cutExtracts sections from lines Parse delimited data cut -d',' -f1 file.csvcat file.csv | cut -d',' -f1 (extracts first column)pasteMerges lines of files Combine data paste file1.txt file2.txtpaste file1.txt file2.txt | sort (merges and sorts)wcCounts lines, words, characters Analyze text wc -l file.txtcat file.txt | wc -w (counts words)trTranslates characters Modify text tr 'a-z' 'A-Z' < file.txtcat file.txt | tr '[:lower:]' '[:upper:]' (converts case)teeWrites to file and stdout Save and display output ls | tee output.txtls -l | tee output.txt | grep "txt" (saves and filters)
 
3. System Information 
Command Description Purpose Basic Example Chaining Example unameShows system information Check OS details uname -auname -r | xargs echo "Kernel:" (displays kernel)hostnameDisplays/sets hostname Identify system hostnamehostname | xargs echo "Host:" (prefixes hostname)uptimeShows system uptime Monitor runtime uptimeuptime | cut -d',' -f1 (extracts uptime)whoamiShows current user Verify identity whoamiwhoami | xargs echo "User:" (prefixes user)idShows user/group IDs Check permissions idid | grep "uid" (filters UID)lscpuDisplays CPU info Check processor details lscpulscpu | grep "Model name" (shows CPU model)lsblkLists block devices View disk layout lsblklsblk | grep "disk" (filters disks)freeShows memory usage Monitor RAM free -hfree -h | grep "Mem" (shows memory line)topMonitors processes View system activity toptop -bn1 | grep "load average" (shows load)htopInteractive process viewer Manage processes htophtop -u user | grep "process" (filters user processes)psLists processes Check running tasks ps auxps aux | grep "httpd" (finds httpd processes)killTerminates processes Stop tasks kill 1234ps aux | grep "process" | awk '{print $2}' | xargs kill (kills process)
 
4. Network 
Command Description Purpose Basic Example Chaining Example pingTests network connectivity Check host reachability ping -c 4 google.comping -c 1 google.com || echo "No connection" (handles failure)ifconfigConfigures network interfaces View network settings ifconfigifconfig | grep "inet" (shows IP addresses)ipManages network settings Modern network tool ip addr showip addr show | grep "inet" (filters IPs)netstatShows network connections Monitor network netstat -tulnnetstat -tuln | grep ":80" (filters port 80)ssInvestigates sockets View connections ss -tulnss -tuln | grep "80" (filters port 80)tracerouteTraces packet routes Diagnose network paths traceroute google.comtraceroute google.com | tail -n 5 (shows last hops)nslookupQueries DNS servers Resolve domains nslookup google.comnslookup google.com | grep "Address" (shows IPs)digPerforms DNS lookups Detailed DNS info dig google.comdig google.com | grep "ANSWER" (shows answers)wgetDownloads files Fetch web content wget http://example.com/filewget -qO- http://example.com | grep "title" (fetches and searches)curlTransfers data API/web requests curl http://example.comcurl -s http://example.com | grep "html" (fetches silently)scpSecurely copies files Transfer between hosts scp file.txt user@host:/pathscp file.txt user@host:/path && ssh user@host ls (copies and lists)sshConnects to remote hosts Remote management ssh user@hostssh user@host "ls -l" | grep "file" ( AscendingOrder:
 
5. User and Permission Management 
Command Description Purpose Basic Example Chaining Example useraddCreates new user Add accounts useradd -m johnuseradd -m john && passwd john (adds user and sets password)usermodModifies user account Update user settings usermod -aG sudo johnusermod -aG sudo john && groups john (adds to group and verifies)userdelDeletes user account Remove users userdel -r johnuserdel -r john || echo "User not found" (handles errors)passwdChanges passwords Secure accounts passwd johnpasswd john && echo "Password updated" (confirms update)sudoRuns commands as another user Execute with privileges sudo apt updatesudo apt update && sudo apt upgrade (updates system)suSwitches user Change identity su - johnsu - john -c "whoami" | grep "john" (verifies user)chownChanges file ownership Assign owners chown john file.txtchown john file.txt && ls -l (changes and verifies)chmodChanges file permissions Set access rights chmod 755 file.txtchmod 755 file.txt && ls -l (sets and verifies)umaskSets default permissions Control new file permissions umask 022umask 022 && touch file.txt && ls -l (sets and tests)
 
6. Package Management 
Command Description Purpose Basic Example Chaining Example aptManages Debian packages Install/update software apt updateapt update && apt install nginx (updates and installs)yumManages RPM packages Install software (CentOS) yum install httpdyum update && yum install httpd (updates and installs)dnfModern RPM package manager Install software (Fedora) dnf install vimdnf update && dnf install vim (updates and installs)pacmanManages Arch packages Install software pacman -S vimpacman -Syu && pacman -S vim (updates and installs)dpkgInstalls Debian packages Manage .deb files dpkg -i package.debdpkg -i package.deb && apt install -f (installs and fixes)
 
7. Process Management 
Command Description Purpose Basic Example Chaining Example killallKills processes by name Stop multiple processes killall firefoxkillall firefox || echo "No firefox running" (handles errors)pkillKills processes by name Stop processes pkill -9 sshdpkill sshd && echo "Processes killed" (confirms kill)niceSets process priority Control resource usage nice -n 10 commandnice -n 10 sleep 10 && echo "Done" (runs with priority)reniceChanges running process priority Adjust priority renice 10 1234renice 10 1234 && ps -p 1234 (changes and verifies)bgRuns job in background Manage jobs bg %1jobs | grep "stopped" | xargs bg (resumes stopped jobs)fgBrings job to foreground Manage jobs fg %1jobs | grep "running" | xargs fg (brings to foreground)jobsLists active jobs Monitor jobs jobsjobs | grep "running" (filters running jobs)
 
8. Disk and Filesystem 
Command Description Purpose Basic Example Chaining Example mountMounts filesystems Access disks mount /dev/sda1 /mntmount /dev/sda1 /mnt && ls /mnt (mounts and lists)umountUnmounts filesystems Detach disks umount /mntumount /mnt || echo "Unmount failed" (handles errors)fdiskManages partitions Create partitions fdisk /dev/sdafdisk -l | grep "/dev/sda" (lists partitions)mkfsCreates filesystems Format disks mkfs.ext4 /dev/sda1mkfs.ext4 /dev/sda1 && mount /dev/sda1 /mnt (formats and mounts)fsckChecks/repairs filesystems Fix disk errors fsck /dev/sda1fsck /dev/sda1 || echo "Errors found" (handles errors)
 
9. Shell and Scripting 
Command Description Purpose Basic Example Chaining Example echoPrints text Display variables/messages echo "Hello"echo $PATH | tr ':' '\n' (splits PATH)printfFormats text Precise output formatting printf "Value: %s\n" "test"printf "%s\n" *.txt | sort (lists and sorts files)aliasCreates command shortcuts Simplify commands alias ll='ls -l'alias ll='ls -l' && ll (sets and uses alias)historyShows command history Review past commands historyhistory | grep "git" (filters git commands)envShows environment variables Check settings envenv | grep "PATH" (filters PATH)
 
10. Other Utilities 
Command Description Purpose Basic Example Chaining Example manDisplays command manuals Learn command usage man lsman ls | less (paginates manual)whatisShows command description Quick command info whatis lswhatis ls | grep "list" (filters description)whereisLocates command files Find binaries whereis lswhereis ls | cut -d' ' -f2 (extracts path)clearClears terminal Clean screen clearls && clear (lists then clears)watchRuns command periodically Monitor changes watch -n 1 'date'watch -n 1 'df -h' | grep "/dev/sda" (monitors disk)
 
Notes 
Distribution-Specific Commands : Commands like apt (Debian/Ubuntu), yum (CentOS), or pacman (Arch) are specific to certain Linux distributions. Verify compatibility with your system. 
Advanced Chaining : The chaining examples here are simplified. Combine multiple commands for more complex tasks as you gain experience. 
Documentation : Always consult man pages or online resources for detailed command options and advanced usage. 
Safety First : Commands like rm, kill, or mkfs can cause data loss or system issues if misused. Double-check before executing. 
 
Why This Cheat Sheet Rocks 
This cheat sheet isn’t just a list—it’s a roadmap to Linux mastery. Each command comes with practical examples and chaining ideas to help you work smarter, not harder. Bookmark this page, share it with your fellow hackers, and revisit it whenever you need to conquer the terminal. Stay curious, keep experimenting, and happy hacking!
Originally published on SquidHacker  – Your source for Linux tips, cybersecurity, and tech tutorials.