The commands you'll use 80% of the time
lsList filescdChange directorypwdPrint working directorycpCopy files/dirsmvMove or renamermRemove files/dirsmkdirCreate directorycatPrint file contentsgrepSearch text patternschmodChange permissionssudoRun as rootsshRemote logincurlTransfer data / HTTPpsList processeskillTerminate processtarArchive & compressfindSearch for filesdfDisk free spaceechoPrint text / variablesmanManual pagesls -laList all + permissionsls -lhSSort by sizetree -L 2Directory treecp file dstCopy filecp -r dir/ dst/Copy directorymv old newRename filemv file dir/Move to dirrm fileDelete filerm -rf dir/Delete directorymkdir -p a/b/cNested dirstouch file.txtEmpty fileln -s target linkSymbolic linkreadlink linkShow link target$find — Search by file attributes
find / -name '*.log'By filename patternfind . -type f -size +100MFiles over 100MBfind . -mtime -7Modified in last 7 daysfind . -type f -emptyEmpty filesfind . -perm 777Files with 777 permsfind . -name '*.tmp' -deleteFind AND delete$grep — Search inside files
grep 'text' fileBasic searchgrep -rn 'text' .Recursive + line numbersgrep -i 'text' fileCase-insensitivegrep -v 'exclude'Lines NOT matchinggrep -E 'a|b' fileRegex ORgrep -l 'text' *.pyOnly filenames$Quick lookups
locate filenameFast indexed searchwhich cmdWhere is this binary?whereis cmdBinary + man + sourcetype cmdHow shell resolves cmdCommon pipeline pattern
$Read & View
cat filePrint entire fileless fileScrollable viewer (q quit)head -n 20 fileFirst 20 linestail -n 20 fileLast 20 linestail -f logfileFollow in real time$Sort, Filter, Count
sort fileSort alphabeticallysort -n -r fileNumeric, reverseduniqRemove adjacent dupessort | uniq -cCount occurrenceswc -l fileCount lineswc -w fileCount wordscut -d',' -f1,3Extract CSV columnstr 'A-Z' 'a-z'Lowercase$sed — Stream editor
sed 's/old/new/g' fReplace all occurrencessed -i 's/old/new/g' fIn-place editsed -n '5,10p' fPrint lines 5–10sed '/^$/d' fDelete empty lines$awk — Column processor
awk '{print $1, $3}'Print columns 1 and 3awk -F: '{print $1}'Custom delimiterawk '$3>100'Filter by valueawk '{s+=$1} END{print s}'Sum columnawk 'NR==5,NR==10'Print lines 5-10$HTTP & Downloads
curl urlFetch contentcurl -I urlHeaders onlycurl -o file urlDownload to filecurl -X POST -d 'data' urlPOST requestwget urlDownload filewget -q -O - urlDownload to stdout$DNS & Connectivity
ping -c 4 hostTest reachabilitytraceroute hostTrace routedig domainDNS lookupnslookup domainDNS querycurl ifconfig.meYour public IP$SSH & Transfer
ssh user@hostRemote loginssh -i key user@hostLogin with keyscp file user@h:/pathCopy to remotersync -avz src/ h:dst/Sync efficiently$Ports & Sockets
ss -tulnpListening ports + PIDslsof -i :8080What's on port 8080ip addrShow IP addressesip routeShow routing table$ ps aux | head -3
USER PID %CPU %MEM COMMAND
root 1 0.0 0.1 /sbin/init
root 2 0.0 0.0 [kthreadd]
$View Processes
ps auxAll processesps aux | grep nameFilter by nametopLive monitorhtopBetter monitor (install)pgrep -f nameGet PID by name$Kill & Signal
kill PIDTERM (15)
Graceful
kill -9 PIDKILL (9)
Force
kill -1 PIDHUP (1)
Reload
killall nameKill all by namepkill -f patternKill by pattern$Background Jobs
cmd &Run in backgroundnohup cmd &Survive logoutjobsList background jobsfg %1Bring to foregroundbg %1Resume in background$System Info
uname -aKernel infouptimeUptime + loadfree -hMemory usagelscpuCPU infohostnameMachine namedateDate & timechmod 755 filerwxr-xr-x (scripts, dirs)chmod 644 filerw-r--r-- (regular files)chmod 600 filerw------- (secrets)chmod +x fileAdd execute permissionchmod -R 755 dir/Recursive permission set$Ownership
chown user fileChange ownerchown user:group fileChange owner + groupchown -R user dir/Recursivechgrp group fileChange group only$Sudo & Users
sudo cmdRun as rootsudo -u user cmdRun as another usersudo -iRoot interactive shellwhoamiCurrent usernameidUID, GID, groups$Space Usage
df -hFilesystem disk usagedu -sh *Size of each item heredu -sh /pathTotal size of pathdu -h --max-depth=1 /Top-level dir sizesncdu /Interactive analyzer$Devices
lsblkList block devicesfdisk -lDisk partitionsmount /dev/sdb1 /mntMount partitionumount /mntUnmountblkidUUIDs + FS typestar syntax breakdown
tar -czf out.tar.gz dir/Create gzip archivetar -xzf file.tar.gzExtract gzip archivetar -xzf f.tar.gz -C /dstExtract to directorytar -tzf file.tar.gzList contents onlytar -cjf out.tar.bz2 dir/Create bzip2 archive$Other formats
gzip fileCompressgunzip f.gzDecompresszip -r o.zip dir/Create zipunzip f.zipExtract zip$systemctl — Service Control
systemctl start svcStart servicesystemctl stop svcStop servicesystemctl restart svcRestart servicesystemctl status svcCheck statussystemctl enable svcStart on bootsystemctl disable svcDon't start on boot$Logs
journalctl -u svcService logsjournalctl -fFollow all logsdmesg | tailKernel messagestail -f /var/log/syslogSystem log$Cron Scheduling
*/5 * * * *Every 5 min0 * * * *Every hour0 2 * * *Daily 2 AM0 0 * * 0Weekly Sun30 9 * * 1-5Weekdays 9:30crontab -e to edit, crontab -l to list
Copy-paste solutions to common problems
Find large files
find / -type f -size +500M -exec ls -lh {} \;Kill port 3000
lsof -ti :3000 | xargs kill -9Count files in dir
find . -type f | wc -lTop 10 largest dirs
du -sh */ | sort -rh | head -10Replace in all files
find . -name '*.py' -exec sed -i 's/old/new/g' {} +Watch log for errors
tail -f /var/log/syslog | grep -i errorDisk hogs
du -h --max-depth=1 / 2>/dev/null | sort -rh | headEmpty all .log files
find . -name '*.log' -exec truncate -s 0 {} +List open ports
ss -tulnp | grep LISTENUnique IPs from log
awk '{print $1}' access.log | sort -u | wc -l$History Tricks
!!Repeat last commandsudo !!Last cmd as root!$Last argument!cmdLast cmd starting with...This Linux commands cheat sheet is a task-oriented reference for every command you'll need on the command line. Instead of alphabetical lists, commands are organized by what you're trying to do — find files, search text, manage processes, transfer data, and more.
Our Linux command line cheat sheet covers the top 20 most-used commands, file operations (copy, move, delete, link), search tools (find, grep, locate), text processing (sed, awk, sort, cut), networking (curl, SSH, rsync, ports), process management (ps, kill, jobs), permissions (chmod, chown, sudo), disk usage, archive commands with tar syntax breakdowns, systemd services, cron scheduling, and copy-paste power one-liners for common tasks.
Whether you're a beginner learning the basic Linux commands or a sysadmin looking for a quick reference, this cheat sheet puts every essential command in one view — organized by task, with real syntax you can copy-paste directly into your terminal.
The top 20 most used Linux commands are: ls, cd, pwd, cp, mv, rm, mkdir, cat, grep, chmod, sudo, ssh, curl, ps, kill, tar, find, df, echo, and man. These cover file management, text search, permissions, networking, processes, and system info — roughly 80% of daily command-line tasks.
Use 'find' to search by file attributes: 'find / -name "*.log"' searches by name, 'find . -size +100M' finds large files, 'find . -mtime -7' finds recently modified files. Use 'grep -rn "text" .' to search inside files. Use 'locate filename' for fast indexed searches (requires updatedb).
grep searches for patterns and prints matching lines — use it to find things. sed is a stream editor that transforms text — use it for find-and-replace operations. awk processes columnar data — use it to extract, filter, and compute on specific fields. A common pipeline chains all three: grep to filter, sed to transform, awk to format output.
Use 'ss -tulnp' to see all listening ports with their process IDs, or 'lsof -i :8080' to check a specific port. 'netstat -tulnp' does the same but is considered legacy. These commands typically require sudo for full output.
For tar.gz: 'tar -czf archive.tar.gz dir/' to create, 'tar -xzf archive.tar.gz' to extract. The flags mean: c=create, x=extract, z=gzip, f=file. For zip: 'zip -r archive.zip dir/' to create, 'unzip archive.zip' to extract. Use 'tar -tzf archive.tar.gz' to list contents without extracting.
Essential one-liners: 'lsof -ti :3000 | xargs kill -9' (kill process on port), 'du -sh */ | sort -rh | head -10' (top 10 largest dirs), 'find . -name "*.log" -exec truncate -s 0 {} +' (empty all log files), 'tail -f /var/log/syslog | grep -i error' (watch for errors in real time), and 'awk "{print $1}" access.log | sort -u | wc -l' (count unique IPs).
Practice with an AI interviewer that tests your Linux knowledge, coding skills, and problem-solving ability in real time.
Try Crackr freearrow_forwardConcepts + commands with visual diagrams
CIDR, subnet masks, VLSM reference
Load balancing, caching, databases
Time & space complexity reference
See DSA in action
Real interview questions by company