Skip to main content
ID Academia
Linux
Beginner10 minLast updated: Topic 3 of 3

Linux cheat sheet — commands on one page

Files, search, processes, permissions, archives, network, shortcuts, Vim and cron — command and example.

Not read

What you will learn here

  • All core commands on one page
  • A ready example for every command
  • Shortcuts, Vim and cron

Worth reading first:Linux command table — from basics to advanced

A quick reference for the whole Linux track: command, what it does and an example. Technical terms stay in English, as at work.

General command pattern

command [-argument] [--long-argument] file
text
CommandWhat it does
Command
cd dir; ls
What it does; — run in sequence, even if the previous one failed
Command
mkdir proj && cd proj
What it does&& — runs only if the previous one succeeded
Command
ping -c1 host || echo "down"
What it does|| — runs only if the previous one failed
Command
long-task &
What it does& — run in the background
Command
cmd1 | cmd2
What it does| — output of one becomes input of the next
Command
TAB
What it doesAuto-complete commands, files and paths
Command
history / !100
What it doesCommand history; !100 re-runs line 100
Command
ls -la
What it doesShows hidden files too (names starting with a dot)

📁 Files and directories

CommandWhat it does
Command
ls -la
What it doesList directory contents with details and hidden files
Command
cd /var/log · cd ~ · cd -
What it doesChange directory; ~ home, - back to previous
Command
pwd
What it doesCurrent path
Command
mkdir -p a/b/c
What it doesCreate a directory including parents
Command
rm -r dir · rm -f file
What it doesDelete — there is no recycle bin!
Command
cp -r src/ dst/
What it doesCopy
Command
mv old.txt new.txt
What it doesMove or rename
Command
ln -s target link
What it doesCreate a symbolic link
Command
touch file.txt
What it doesCreate a file or update its timestamp

🔍 Searching

CommandWhat it does
Command
grep -r "error" /var/log
What it doesSearch text inside files
Command
find / -name "*.conf" 2>/dev/null
What it doesFind files by attributes
Command
locate passwd
What it doesFast search from a database (needs updatedb)
Command
which python3
What it doesWhere a command lives
Command
grep Failed auth.log | cut -d' ' -f11 | sort | uniq -c | sort -rn | head
What it doesTypical log chain: who failed to log in most often

⚙️ Processes

CommandWhat it does
Command
ps aux · ps aux | grep nginx
What it doesRunning processes
Command
kill -9 PID
What it doesStop a process (-9 = SIGKILL, last resort)
Command
killall firefox
What it doesStop by name
Command
top · htop
What it doesLive view and process management
Command
jobs · fg %1 · Ctrl+Z → bg
What it doesMove jobs between background and foreground

🔐 Permissions

order: owner / group / world
r = read (4) · w = write (2) · x = execute (1)
chmod 755 file → rwx owner, r-x group/world
chmod 777 file → rwx for everyone (avoid!)
text
CommandWhat it does
Command
chmod 644 file · chmod u+x script.sh
What it doesChange permissions
Command
sudo chown user:group file
What it doesChange owner
Command
umask
What it doesDefault mask: 022 = files 644
Command
id alice · groups
What it doesWho am I and which groups

🗜️ Archives and compression

CommandWhat it does
Command
tar -czvf a.tar.gz dir/
What it doesCreate a compressed archive
Command
tar -xzvf a.tar.gz -C /restore/
What it doesExtract
Command
tar -tzvf a.tar.gz
What it doesList contents — before extracting!
Command
gzip -k file.log · gunzip
What it doesCompress one file (-k keeps the original)
Command
zcat log.gz | tail
What it doesView a compressed file

🌐 Network

CommandWhat it does
Command
ping -c 4 8.8.8.8
What it doesReachability and latency
Command
ip a · ip r
What it doesIP addresses and routing table
Command
ss -tulpn
What it doesOpen ports and the listening process
Command
dig +short example.com · nslookup
What it doesDNS query
Command
curl -I https://site.com
What it doesHTTP check
Command
wget -O out.zip URL
What it doesDownload a file
Command
ssh -p 2222 user@host
What it doesRemote login
Command
scp file user@host:/tmp/
What it doesCopy over SSH

💻 System info

CommandWhat it does
Command
uname -a
What it doesKernel and system version
Command
cat /etc/os-release
What it doesWhich distribution is installed
Command
df -h
What it doesDisk usage — the most important!
Command
du -sh /var/*
What it doesWhat takes up space
Command
free -h
What it doesMemory (cache is not really used memory)
Command
uptime
What it doesUptime and load average
Command
who · w
What it doesWho is logged in
Command
journalctl -p err --since today
What it doesToday's errors

⌨️ Terminal shortcuts

CommandWhat it does
Command
Ctrl+C
What it doesStop the current command
Command
Ctrl+Z
What it doesSuspend to background (fg to resume)
Command
Ctrl+R
What it doesReverse history search
Command
Ctrl+L
What it doesClear the screen (like clear)
Command
Ctrl+A · Ctrl+E
What it doesStart / end of line
Command
Ctrl+U · Ctrl+K
What it doesDelete line backward / forward
Command
Ctrl+D
What it doesExit / EOF (careful as root!)
Command
!! · sudo !!
What it doesRepeat last command; or with sudo

✏️ Vim survival

CommandWhat it does
Command
Esc → :wq
What it doesSave and quit
Command
Esc → :q!
What it doesQuit without saving
Command
i
What it doesEnter insert mode
Command
/text + Enter · n
What it doesSearch; n for next match
Command
dd · u · Ctrl+R
What it doesDelete line, undo, redo
Command
o · O
What it doesNew line below / above
Command
:N · G · gg
What it doesJump to line N / end / start

⏰ cron and ufw

crontab -e                    # edit scheduler
crontab -l                    # list
0 3 * * * /home/u/backup.sh   # min hour day month weekday
sudo ufw allow 22/tcp && sudo ufw enable   # SSH first, then enable
sudo ufw status verbose
bash

Check yourself

Score: 0 of 0

Great! You got the material.

Was this page helpful?