Linux Cheat Sheet

crackr.dev

1Files & Directories

File System Hierarchy

/ 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 path
cd ~Go home
cd -Go back
ls -laList all + details
ls -lhSList by size

$Create, Copy, Move, Delete

mkdir -p a/b/cCreate nested dirs
touch file.txtCreate empty file
cp -r src/ dst/Copy dir recursively
mv old newMove / rename
rm -rf dir/Delete dir + contents
ln -s target linkSymbolic link

$Find Files

find / -name '*.log'By name
find . -size +100MBy size
find . -mtime -7Modified last 7 days
locate filenameFast indexed search
which cmdWhere is binary?

2File Permissions

Permission Structure
-rwxr-xr--
Owner (7)
Group (5)
Others (4)
= chmod 754

$Octal Values

0

---

1

--x

2

-w-

3

-wx

4

r--

5

r-x

6

rw-

7

rwx

$Most Used

755rwxr-xr-xscripts, directories
644rw-r--r--regular files
600rw-------SSH keys, secrets
777rwxrwxrwx⚠ avoid in production
chmod 755 fileSet permissions (octal)
chmod +x script.shMake executable
chown user:grp fileChange owner + group
chown -R user dir/Recursive ownership

3I/O Redirection & Pipes

stdinfd 0commandprocessstdoutfd 1stderrfd 2→ file→ file
>Redirect stdout (overwrite)echo hi > file
>>Append stdoutecho hi >> file
2>Redirect stderrcmd 2> err.log
&>Redirect bothcmd &> all.log
|Pipe to next commandls | grep .txt
<Read stdin from filecmd < input

$Patterns You'll Use Daily

cmd > /dev/null 2>&1Discard all output
cmd | tee fileScreen AND file
cmd1 && cmd2Run cmd2 if cmd1 succeeds
cmd1 || cmd2Run cmd2 if cmd1 fails
cmd | xargs rmPipe as arguments

4Text Processing

grep

search

sed

replace

awk

transform

$grep — Search

grep -rn 'pattern' .Recursive + line numbers
grep -i 'text' fileCase-insensitive
grep -v 'exclude'Invert (exclude lines)
grep -c 'x' fileCount matches
grep -E 'a|b'Extended regex (OR)

$sed — Find & Replace

sed 's/old/new/g' fReplace all in file
sed -i 's/old/new/g' fIn-place replace
sed -n '5,10p' fPrint lines 5–10
sed '/pattern/d' fDelete matching lines

$awk — Column Processing

awk '{print $1}'Print first column
awk -F: '{print $1}'Custom delimiter (:)
awk '$3 > 100'Filter by column value
awk '{s+=$1} END{print s}'Sum a column

$View & Count

cat filePrint file
less fileScrollable
head -20 fFirst 20 lines
tail -f logFollow live
wc -l fileCount lines
sort | uniq -cDedupe + count

5Process Management

RunningStoppedZombieDeadCtrl+Zfg/bgkillexit (no wait)

$View Processes

ps auxAll running processes
ps aux | grep nginxFind specific process
top / htopLive process monitor
pgrep -f nameFind PID by name
lsof -i :8080What's on port 8080

$Kill Signals

15

SIGTERM

Graceful

9

SIGKILL

Force kill

1

SIGHUP

Reload

kill PIDSIGTERM (graceful)
kill -9 PIDSIGKILL (force)
killall nameKill all by name
cmd &Run in background
nohup cmd &Survive logout
jobs / fg / bgJob control

6Networking

$Connectivity & DNS

ping -c 4 hostTest connectivity
traceroute hostTrace packet route
dig domainDNS lookup
curl -I urlHTTP headers only
curl ifconfig.meYour public IP
wget -q url -O outDownload file

$Ports & Connections

ss -tulnpListening ports + PIDs
netstat -tulnpSame (legacy)
lsof -i :80What's on port 80

$SSH & File Transfer

ssh user@hostRemote login
ssh -i key.pem u@hLogin with key
ssh -L 8080:localhost:80 hPort forward
scp file user@h:/pathCopy to remote
scp -r dir u@h:/pCopy dir to remote
rsync -avz src/ h:dst/Efficient sync
ip addrShow IP addresses
ip routeRouting table

7Package Management

Debian / Ubuntu
apt updateRefresh index
apt install pkgInstall
apt remove pkgRemove
apt upgradeUpgrade all
apt search pkgSearch
dpkg -lList installed
RHEL / Fedora
dnf check-updateRefresh
dnf install pkgInstall
dnf remove pkgRemove
dnf upgradeUpgrade all
dnf search pkgSearch
rpm -qaList installed
Alpine (Docker)
apk add --no-cache pkgInstall
apk del pkgRemove

8Systemd & Services

inactive
starting
active
stopping
dead

$Control Services

systemctl start svcStart
systemctl stop svcStop
systemctl restart svcRestart
systemctl reload svcReload config (no downtime)
systemctl status svcCheck status

$Boot & Discovery

systemctl enable svcStart on boot
systemctl disable svcDon't start on boot
systemctl list-unitsActive units
journalctl -u svcView service logs
journalctl -fFollow system logs

9Cron Scheduling

Crontab format — 5 fields + command

*****cmd
minhourdaymonthweekday
0-590-231-311-120-6

$Common Schedules

*/5 * * * *Every 5 minutes
0 * * * *Every hour
0 2 * * *Daily at 2 AM
0 0 * * 0Weekly (Sunday)
0 0 1 * *Monthly (1st)
30 9 * * 1-5Weekdays 9:30 AM
crontab -eEdit crontab
crontab -lList cron jobs

10Compression & Archives

$tar — Flags Explained

-cCreate
-xExtract
-tList
-zgzip
-jbzip2
-vVerbose
-fFile
tar -czf out.tar.gz dir/Create gzip archive
tar -xzf file.tar.gzExtract gzip archive
tar -xzf f.tar.gz -C /dstExtract to specific dir
tar -tzf file.tar.gzList contents

$Others

gzip fileCompress
gunzip f.gzDecompress
zip -r o.zip dir/Create zip
unzip f.zipExtract zip

11Disk, Users & System

$Disk Space

df -hDisk usage by filesystem
du -sh *Size of each item here
du -h --max-depth=1Subdirectory sizes
ncdu /Interactive analyzer
lsblkList block devices

$Users & Groups

whoamiCurrent user
idUID, GID, groups
useradd -m userCreate user + home
passwd userSet password
usermod -aG grp userAdd to group
sudo -iRoot shell

$System Info

uname -aKernel info
uptimeSystem uptime
free -hMemory usage
lscpuCPU info
hostnameMachine name
dateCurrent time

12Shell Shortcuts & Tricks

Works in bash, zsh, and most shells

$Cursor & Editing

Ctrl+AStart of line
Ctrl+EEnd of line
Ctrl+WDelete word ←
Ctrl+KDelete to end
Ctrl+UDelete to start
Ctrl+YPaste deleted

$Control

Ctrl+CKill process
Ctrl+ZSuspend
Ctrl+DExit / EOF
Ctrl+LClear screen
Ctrl+RHistory search
TabAutocomplete

$History Tricks

!!Repeat last command
sudo !!Last cmd as root
!$Last argument of prev cmd
history | grep xSearch history

The 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_forward

Continue learning