ENGIMY.IO - CHEATSHEET
LINUX × QUICK REFERENCE
REFERENCE v1.0

Linux Commands Quick Reference

Everything you need day‑to‑day – from basic navigation to advanced system administration.

File & Directory Commands

Command Description Example
ls List directory contents ls -la
cd Change directory cd /home/user
pwd Print working directory pwd
mkdir Create directory mkdir -p dir/subdir
rmdir Remove empty directory rmdir dir
rm Remove files/directories rm -rf dir
cp Copy files/directories cp -r src dest
mv Move/rename files mv file1 file2
touch Create empty file or update timestamp touch file.txt
ln Create links ln -s target link
find Search for files find . -name "*.txt"
locate Find files (updatedb database) locate file.txt
which Show location of command which python
stat File information stat file.txt

Viewing Files

Command Description Example
cat Display entire file cat file.txt
less View file interactively less file.txt
more View file page by page more file.txt
head First lines of file head -n 20 file.txt
tail Last lines of file tail -f file.txt
wc Word/line/char count wc -l file.txt
diff Compare files diff file1 file2
file Determine file type file file.txt

Permissions

Command Description Example
chmod Change permissions chmod 755 file
chown Change owner chown user:group file
chgrp Change group chgrp users file
umask Default file permissions umask 022
lsattr List file attributes lsattr file
chattr Change file attributes chattr +i file

Permission Numeric Values

  • 4 – read (r)
  • 2 – write (w)
  • 1 – execute (x)
  • 7 – rwx (4+2+1)
  • 6 – rw- (4+2)
  • 5 – r-x (4+1)
  • 4 – r-- (4)

Process Management

Command Description Example
ps List processes ps aux
top Interactive process viewer top
htop Better interactive process viewer htop
kill Send signal to process kill -9 PID
pkill Kill process by name pkill firefox
killall Kill all processes by name killall firefox
nice Set process priority nice -n 10 command
renice Change process priority renice 10 PID
jobs List background jobs jobs
bg Resume background job bg %1
fg Resume foreground job fg %1
nohup Run command even after logout nohup command &

Process Signals

  • SIGTERM (15) – graceful termination
  • SIGKILL (9) – force kill
  • SIGHUP (1) – reload configuration
  • SIGSTOP (19) – pause process
  • SIGCONT (18) – resume paused process

Text Processing

Command Description Example
grep Search for pattern grep -r "pattern" .
sed Stream editor sed 's/old/new/g' file
awk Text processing language awk '{print $1}' file
cut Cut columns/fields cut -d',' -f1 file.csv
sort Sort lines sort -n file
uniq Unique lines sort file | uniq -c
wc Word count wc -l file
tr Translate/delete characters tr 'a-z' 'A-Z'
head First lines head -n 10 file
tail Last lines tail -n 10 file

grep Patterns

  • grep pattern file – search file
  • grep -i – case‑insensitive
  • grep -v – invert match
  • grep -r – recursive
  • grep -E – extended regex
  • grep -c – count matches
  • grep -n – show line numbers
  • grep -A 3 – show 3 lines after match

sed Examples

  • sed 's/old/new/g' – replace all
  • sed -n '5p' – print line 5
  • sed '/pattern/d' – delete matching lines
  • sed -i – in‑place edit
  • sed '1,5d' – delete lines 1‑5

System Information

Command Description Example
uname System information uname -a
df Disk usage df -h
du Directory size du -sh dir
free Memory usage free -h
uptime System uptime uptime
who Logged in users who
w Logged in users + activity w
whoami Current user whoami
id User/group info id user
date Current date/time date
cal Calendar cal 2024

Networking

Command Description Example
ping Test connectivity ping google.com
curl Transfer data from URL curl http://example.com
wget Download file wget http://example.com/file
ifconfig Network interfaces ifconfig
ip Advanced network config ip addr
nslookup DNS lookup nslookup google.com
dig DNS query tool dig google.com
netstat Network statistics netstat -tuln
ss Socket statistics ss -tuln
traceroute Trace route traceroute google.com
telnet Connect to port telnet localhost 80
ssh Secure shell ssh user@host
scp Secure copy scp file user@host:/path
rsync Remote sync rsync -av src/ dest/

Archiving & Compression

Command Description Example
tar Archive files tar -czf archive.tar.gz dir/
gzip Compress with gzip gzip file
gunzip Decompress gzip gunzip file.gz
zip Create zip archive zip archive.zip file
unzip Extract zip unzip archive.zip
zcat View gzipped file zcat file.gz

tar Flags

  • -c – create archive
  • -x – extract archive
  • -z – gzip compression
  • -j – bzip2 compression
  • -v – verbose
  • -f – file
  • -t – list contents

User Management

Command Description Example
useradd Create user useradd -m -s /bin/bash user
usermod Modify user usermod -aG sudo user
userdel Delete user userdel -r user
passwd Change password passwd user
groupadd Create group groupadd group
groupdel Delete group groupdel group
groups Show user groups groups user
su Switch user su - user
sudo Execute as superuser sudo command

Package Management

Debian/Ubuntu (apt)

  • apt update – update package lists
  • apt upgrade – upgrade packages
  • apt install package – install package
  • apt remove package – remove package
  • apt purge package – remove with config
  • apt search pattern – search packages
  • apt show package – show package info
  • apt list --installed – list installed packages

RedHat/CentOS/Fedora (yum/dnf)

  • yum update / dnf update – update
  • yum install package / dnf install package
  • yum remove package / dnf remove package
  • yum search pattern / dnf search pattern
  • yum info package / dnf info package

Arch Linux (pacman)

  • pacman -Syu – update
  • pacman -S package – install
  • pacman -R package – remove
  • pacman -Qs pattern – search
  • pacman -Qi package – info

Snap

  • snap install package – install snap
  • snap remove package – remove snap
  • snap refresh – update snaps
  • snap find pattern – search
  • snap list – list installed snaps

Flatpak

  • flatpak install flathub package – install
  • flatpak remove package – remove
  • flatpak update – update
  • flatpak list – list installed
  • flatpak search pattern – search

Miscellaneous Commands

Command Description Example
echo Print to stdout echo "Hello"
clear Clear terminal clear
history Command history history | grep command
alias Create alias alias ll='ls -la'
unalias Remove alias unalias ll
exit Exit shell exit
sleep Delay execution sleep 5
time Measure execution time time command
watch Execute periodically watch -n 2 command

Keyboard Shortcuts

  • Ctrl + C – interrupt current process
  • Ctrl + Z – suspend process
  • Ctrl + D – EOF / exit shell
  • Ctrl + L – clear terminal
  • Ctrl + R – reverse history search
  • Ctrl + A – move to beginning of line
  • Ctrl + E – move to end of line
  • Ctrl + U – delete from cursor to beginning
  • Ctrl + K – delete from cursor to end
  • Ctrl + W – delete previous word
  • Ctrl + Shift + C – copy
  • Ctrl + Shift + V – paste
  • Tab – autocomplete
  • / – command history
📌 Quick Reference
Navigate: ls, cd, pwd, mkdir, rm, cp, mv
View: cat, less, head, tail, grep
Process: ps, top, kill, bg, fg
Text: grep, sed, awk, cut, sort, uniq
System: df, du, free, uptime, uname
Network: ping, curl, ssh, scp, netstat
Archives: tar, gzip, zip, unzip
Package: apt (Debian), yum/dnf (RHEL), pacman (Arch)
← Back to All Cheatsheets