Linux Cheat Sheet
1Files & Directories
/ root of everything
├── home/ user directories
├── etc/ config files
├── var/ logs, runtime data
├── usr/ installed programs
├── tmp/ temporary files
├── opt/ third-party software
└── dev/ device files
Navigation
pwdWhere am I?cd /pathGo to pathcd ~Go homecd -Go backls -laList all + detailsls -lhSList by sizeCreate, Copy, Move, Delete
mkdir -p a/b/cCreate nested dirstouch file.txtCreate empty filecp -r src/ dst/Copy dir recursivelymv old newMove / renamerm -rf dir/Delete dir + contentsln -s target linkSymbolic linkFind Files
find / -name '*.log'By namefind . -size +100MBy sizefind . -mtime -7Modified last 7 dayslocate filenameFast indexed searchwhich cmdWhere is binary?2File Permissions
Octal Values
0
---
1
--x
2
-w-
3
-wx
4
r--
5
r-x
6
rw-
7
rwx
Most Used
chmod 755 fileSet permissions (octal)chmod +x script.shMake executablechown user:grp fileChange owner + groupchown -R user dir/Recursive ownership3I/O Redirection & Pipes
>Redirect stdout (overwrite)echo hi > file>>Append stdoutecho hi >> file2>Redirect stderrcmd 2> err.log&>Redirect bothcmd &> all.log|Pipe to next commandls | grep .txt<Read stdin from filecmd < inputPatterns You'll Use Daily
cmd > /dev/null 2>&1Discard all outputcmd | tee fileScreen AND filecmd1 && cmd2Run cmd2 if cmd1 succeedscmd1 || cmd2Run cmd2 if cmd1 failscmd | xargs rmPipe as arguments4Text Processing
grep
search
sed
replace
awk
transform
grep, Search
grep -rn 'pattern' .Recursive + line numbersgrep -i 'text' fileCase-insensitivegrep -v 'exclude'Invert (exclude lines)grep -c 'x' fileCount matchesgrep -E 'a|b'Extended regex (OR)sed, Find & Replace
sed 's/old/new/g' fReplace all in filesed -i 's/old/new/g' fIn-place replacesed -n '5,10p' fPrint lines 5, 10sed '/pattern/d' fDelete matching linesawk, Column Processing
awk '{print $1}'Print first columnawk -F: '{print $1}'Custom delimiter (:)awk '$3 > 100'Filter by column valueawk '{s+=$1} END{print s}'Sum a columnView & Count
cat filePrint fileless fileScrollablehead -20 fFirst 20 linestail -f logFollow livewc -l fileCount linessort | uniq -cDedupe + count5Process Management
View Processes
ps auxAll running processesps aux | grep nginxFind specific processtop / htopLive process monitorpgrep -f nameFind PID by namelsof -i :8080What's on port 8080Kill Signals
15
SIGTERM
Graceful
9
SIGKILL
Force kill
1
SIGHUP
Reload
kill PIDSIGTERM (graceful)kill -9 PIDSIGKILL (force)killall nameKill all by namecmd &Run in backgroundnohup cmd &Survive logoutjobs / fg / bgJob control6Networking
Connectivity & DNS
ping -c 4 hostTest connectivitytraceroute hostTrace packet routedig domainDNS lookupcurl -I urlHTTP headers onlycurl ifconfig.meYour public IPwget -q url -O outDownload filePorts & Connections
ss -tulnpListening ports + PIDsnetstat -tulnpSame (legacy)lsof -i :80What's on port 80SSH & File Transfer
ssh user@hostRemote loginssh -i key.pem u@hLogin with keyssh -L 8080:localhost:80 hPort forwardscp file user@h:/pathCopy to remotescp -r dir u@h:/pCopy dir to remotersync -avz src/ h:dst/Efficient syncip addrShow IP addressesip routeRouting table7Package Management
apt updateRefresh indexapt install pkgInstallapt remove pkgRemoveapt upgradeUpgrade allapt search pkgSearchdpkg -lList installeddnf check-updateRefreshdnf install pkgInstalldnf remove pkgRemovednf upgradeUpgrade alldnf search pkgSearchrpm -qaList installedapk add --no-cache pkgInstallapk del pkgRemove8Systemd & Services
Control Services
systemctl start svcStartsystemctl stop svcStopsystemctl restart svcRestartsystemctl reload svcReload config (no downtime)systemctl status svcCheck statusBoot & Discovery
systemctl enable svcStart on bootsystemctl disable svcDon't start on bootsystemctl list-unitsActive unitsjournalctl -u svcView service logsjournalctl -fFollow system logs9Cron Scheduling
Crontab format, 5 fields + command
Common Schedules
*/5 * * * *Every 5 minutes0 * * * *Every hour0 2 * * *Daily at 2 AM0 0 * * 0Weekly (Sunday)0 0 1 * *Monthly (1st)30 9 * * 1-5Weekdays 9:30 AMcrontab -eEdit crontabcrontab -lList cron jobs10Compression & Archives
tar, Flags Explained
tar -czf out.tar.gz dir/Create gzip archivetar -xzf file.tar.gzExtract gzip archivetar -xzf f.tar.gz -C /dstExtract to specific dirtar -tzf file.tar.gzList contentsOthers
gzip fileCompressgunzip f.gzDecompresszip -r o.zip dir/Create zipunzip f.zipExtract zip11Disk, Users & System
Disk Space
df -hDisk usage by filesystemdu -sh *Size of each item heredu -h --max-depth=1Subdirectory sizesncdu /Interactive analyzerlsblkList block devicesUsers & Groups
whoamiCurrent useridUID, GID, groupsuseradd -m userCreate user + homepasswd userSet passwordusermod -aG grp userAdd to groupsudo -iRoot shellSystem Info
uname -aKernel infouptimeSystem uptimefree -hMemory usagelscpuCPU infohostnameMachine namedateCurrent time12Shell Shortcuts & Tricks
Cursor & Editing
Control
History Tricks
!!Repeat last commandsudo !!Last cmd as root!$Last argument of prev cmdhistory | grep xSearch historyThe Complete Linux Cheat Sheet
This Linux cheat sheet is a single-screen reference covering every command you need for daily development and system administration. Whether you are SSH'd into a production server, debugging a Docker container, or setting up a new machine, this guide has you covered.
Our Linux commands cheat sheet covers file operations and navigation, file permissions (with octal reference), text processing (grep, sed, awk), I/O redirection and pipes, process management, networking (SSH, curl, ports), package management (apt, dnf, apk), compression, disk usage, user management, systemd services, cron scheduling, environment variables, and essential keyboard shortcuts.
Unlike scattered man pages and blog posts, this Linux command line cheat sheet puts every essential command in one view, organized by category, with real syntax and practical descriptions you can use immediately.
Linux Cheat Sheet FAQ
What is a Linux cheat sheet?expand_more
A Linux cheat sheet is a quick-reference guide listing the most commonly used Linux terminal commands with brief descriptions. It covers file operations, permissions, text processing, process management, networking, and system administration, so you can look up commands instantly instead of searching man pages.
What are the most important Linux commands to know?expand_more
The essential commands are: ls, cd, cp, mv, rm, mkdir (files & dirs), chmod, chown (permissions), grep, sed, awk (text processing), ps, kill, top (processes), ssh, scp, curl (networking), systemctl (services), and tar, gzip (compression). These cover 90% of daily command-line tasks for developers and sysadmins.
How do Linux file permissions work?expand_more
Every file has three permission sets: owner, group, and others. Each set can have read (r=4), write (w=2), and execute (x=1) permissions. Permissions are often written in octal notation, for example, 755 means the owner has full access (7=rwx), while group and others can read and execute (5=r-x). Use chmod to change permissions and chown to change ownership.
What is the difference between grep, sed, and awk?expand_more
grep searches for patterns in text and prints matching lines. sed is a stream editor that transforms text (find-and-replace, delete lines, insert text). awk is a full text processing language that works on columns, it can filter rows, extract fields, do arithmetic, and format output. Use grep to find, sed to replace, and awk to process structured data.
How do I manage services with systemd?expand_more
Use systemctl to control services: 'systemctl start/stop/restart service' to control state, 'systemctl enable/disable service' to control boot behavior, and 'systemctl status service' to check status. Use 'journalctl -u service' to view logs. Most modern Linux distributions (Ubuntu 16+, CentOS 7+, Debian 8+) use systemd.
How does cron scheduling work in Linux?expand_more
Cron uses a five-field format: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-6). Use 'crontab -e' to edit your jobs. Common examples: '0 * * * *' runs every hour, '*/5 * * * *' every 5 minutes, '0 2 * * *' daily at 2 AM. The asterisk (*) means 'every value' for that field.
What are the most useful Linux keyboard shortcuts?expand_more
Essential shortcuts: Ctrl+C (kill process), Ctrl+Z (suspend), Ctrl+D (exit/EOF), Ctrl+L (clear screen), Ctrl+R (search history), Ctrl+A/E (start/end of line), Ctrl+W (delete word), Tab (autocomplete), !! (repeat last command), sudo !! (last command as root). These work in bash and most other shells.
Ready to ace your technical interview?
Practice with an AI interviewer that tests your coding skills, system knowledge, and problem-solving ability in real time.
Try Crackr freearrow_forwardContinue learning
Subnet Cheat Sheet
CIDR, subnet masks, VLSM, and more
System Design Cheat Sheet
Load balancing, caching, databases
Big O Cheat Sheet
Time & space complexity reference
Blind 75
The original 75 LeetCode problems
DSA Tracker
177 problems across 16 DSA topics
Algorithm Visualizers
See DSA in action
Company Questions
Real interview questions by company