Linux Commands Cheat Sheet

Filesystem, commands, users, groups, and permissions essentials for DevOps

← Back to Linux Basics

🐧 Linux Commands Cheat Sheet 

File Commands

Command Description Options Example  
ls List files -lah ls -lah  
cd Change directory .. ~ cd /var/log  
pwd Current directory - pwd  
cp Copy files -rv cp -r a b  
mv Move files -iv mv a b  
rm Delete files -rf rm -rf tmp  
mkdir Create directory -p mkdir -p a/b  
rmdir Remove empty dir - rmdir test  
touch Create empty file - touch f  
stat File stats - stat f  
file Detect file type - file f  
tree Directory tree - tree .  
basename Filename only - basename /a/b  
dirname Directory path - dirname /a/b  
realpath Resolve path - realpath f  
readlink Read symlink -f readlink -f f  
ln Create links -s ln -s a b  
statx Extended stats - statx f  
du Dir size -sh du -sh .  
df Disk usage -h df -h  
watch Repeat command -n watch ls  
find Search files -name find . -name '*.log'  
locate Fast search - locate ssh  
which Binary path - which ls  
whereis Binary locations - whereis bash  
chown Change owner -R chown user f  
chgrp Change group - chgrp dev f  
chmod Change perms 755 chmod 755 f  
setfacl Set ACL -m setfacl -m u:a:r f  
getfacl Get ACL - getfacl f  
sync Flush writes - sync  
copy-progress Copy progress - cp -rv  
statfs FS stats - stat -f .  
pathchk Path validity - pathchk f  
vdir Verbose ls - vdir  
dir List dir - dir  
statx File ext stats - statx f  
shred Overwrite file -u shred f  
unlink Remove file - unlink f  
fallocate Preallocate file -l fallocate -l 1G f  
stat Metadata - stat f  
tempfile Create temp file - tempfile  
chattr File attrs +i chattr +i f  
lsattr List attrs - lsattr f  
rename Batch rename - rename s/a/b/ *  
stat File info - stat f  
statx Kernel stats - statx f  

Text Commands

Command Description Options Example  
cat View file -n cat f  
tac Reverse cat - tac f  
less Pager -N less f  
more Pager - more f  
head First lines -n head -10 f  
tail Last lines -f tail -f f  
wc Count text -l wc -l f  
grep Search text -ir grep err f  
egrep Regex grep - egrep a|b f  
fgrep Fixed grep - fgrep a f  
sed Stream edit -i sed 's/a/b/' f  
awk Text processing - awk '{print }' f  
sort Sort text -nr sort -nr f  
uniq Unique lines -c uniq -c f  
column Align output -t column -t f  
fmt Format text - fmt f  
nl Number lines - nl f  
cut Cut fields -d cut -d: -f1 f  
paste Merge lines - paste f1 f2  
join Join files - join f1 f2  
split Split files -l split -l 100 f  
tr Translate chars - tr a b  
iconv Charset convert - iconv -f a -t b  
dos2unix CRLF fix - dos2unix f  
unix2dos LF to CRLF - unix2dos f  
strings Extract strings - strings bin  
hexdump Hex view -C hexdump -C f  
xxd Hex editor - xxd f  
rev Reverse text - rev f  
fold Line wrap -w fold -w 80 f  
pr Pretty print - pr f  
expand Tabs to spaces - expand f  
unexpand Spaces to tabs - unexpand f  
sha1sum SHA1 hash - sha1sum f  
sha256sum SHA256 hash - sha256sum f  
md5sum MD5 hash - md5sum f  
cksum CRC checksum - cksum f  
base64 Encode/decode -d base64 f  
watch Watch output - watch wc f  
yes Repeat output - yes y  
col Filter output -b col -b  
script Record terminal - script out  
scriptreplay Replay session - scriptreplay  

Process Commands

Command Description Options Example  
ps Process list aux ps aux  
top Live monitor - top  
htop Enhanced top - htop  
atop Advanced monitor - atop  
htop Interactive monitor - htop  
kill Kill PID -9 kill -9 123  
pkill Kill by name -f pkill nginx  
killall Kill all - killall bash  
bg Background job - bg %1  
fg Foreground job - fg %1  
jobs List jobs - jobs  
uptime System uptime - uptime  
tload Terminal load - tload  
watch Repeat command - watch free  
nice Set priority - nice -n 10 cmd  
renice Change priority - renice 10 123  
strace Syscall trace - strace ls  
ltrace Library trace - ltrace ls  
time Time command - time ls  
vmstat Memory stats - vmstat  
iostat IO stats - iostat  
mpstat CPU stats - mpstat  
free Memory usage -h free -h  
uptime Runtime - uptime  
watch Refresh output - watch df  

Network Commands

Command Description Options Example  
ip Network config addr ip a  
ifconfig Legacy net - ifconfig  
ping Connectivity -c ping -c 4 google.com  
curl HTTP client -I curl -I site  
wget Download -c wget url  
ss Socket stats -tulnp ss -tulnp  
netstat Legacy stats -tulnp netstat -tulnp  
traceroute Route trace - traceroute google.com  
tracepath Trace path - tracepath google.com  
nslookup DNS lookup - nslookup google.com  
dig DNS query - dig google.com  
tcpdump Packet capture -i tcpdump -i eth0  
nmap Port scan - nmap localhost  
arp ARP table -a arp -a  
route Routing table -n route -n  
nmcli NetworkManager - nmcli dev status  
iw WiFi config - iw dev  
iwconfig Wireless legacy - iwconfig  
bluetoothctl Bluetooth - bluetoothctl  
ssh Remote shell -i ssh user@host  
scp Secure copy -r scp a host:/tmp  
rsync File sync -avz rsync -avz a b  
ftp FTP client - ftp host  
sftp Secure FTP - sftp host  
nc Netcat - nc -l 8080  
socat Socket relay - socat TCP-LISTEN:80 STDOUT  
ufw Firewall allow ufw allow 22  
iptables Firewall rules - iptables -L  

User Commands

Command Description Options Example  
whoami Current user - whoami  
id User ID - id  
who Logged users - who  
w Who is logged - w  
last Login history - last  
lastlog Last login - lastlog  
su Switch user - su -  
sudo Run as root - sudo cmd  
adduser Add user - adduser test  
deluser Delete user - deluser test  
passwd Change password - passwd user  
groups User groups - groups  
usermod Modify user -aG usermod -aG sudo user  
login Login shell - login  
logout Logout shell - logout  
chsh Change shell - chsh user  
ulimit Resource limits -a ulimit -a  
crontab Schedule jobs -e crontab -e  
at One-time job - at now+1min  

Package Commands

Command Description Options Example  
apt Package manager - apt install nginx  
apt-get Legacy apt - apt-get update  
apt-cache APT cache - apt-cache search nginx  
dpkg Deb tool -i dpkg -i a.deb  
snap Snap packages - snap list  
snapctl Snap control - snapctl services  
flatpak Flatpak mgr - flatpak list  

Archive Commands

Command Description Options Example  
tar Archive files -czf tar -czf a.tgz dir  
gzip Compress file - gzip f  
gunzip Decompress - gunzip f.gz  
zcat View gzip - zcat f.gz  
zip Zip files -r zip -r a.zip dir  
unzip Extract zip - unzip a.zip  
7z 7zip archive a x 7z x a.7z  
ar Archive tool - ar x a.a  
cpio Copy IO - cpio -id