Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Concepts

Linux command cheat sheet

A compact Linux command cheat sheet: navigation, files, text, permissions, processes, disks, networking, archives and Bash shortcuts, with links to full pages.

This page is a quick lookup: the command you want for the job in front of you, in one line, with a link to the full reference page. It covers what most people type every day. Where a command has dozens of options, only the ones you reach for most are listed.

Commands marked (read-only here) are not installed on the site's runner or need real hardware, so the examples are for your own machine. Everything else can be tried in the live examples below.

Terminal
man ls          # the manual for any command
ls --help       # short usage summary
type -a ls      # what will actually run?

Try it

Bash A tour of the basics

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Permissions, text and counting

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Task Command
Where am I? pwd
Change directory (home, previous) cd, cd -
List with details, including hidden ls -lah
Create directories (with parents) mkdir -p a/b/c
Copy a file or a tree cp file dest, cp -r dir dest
Move or rename mv old new
Remove files, a tree rm file, rm -r dir
Create an empty file or update its time touch file
Make a link ln -s target linkname
Show a directory tree tree (read-only here)
File type and metadata file name, stat name

See ls, cp, mv, rm, ln.

Viewing and searching

Task Command
Show a file cat file, less file
First or last lines, follow growth head -n 20 f, tail -n 20 f, tail -f f
Count lines, words, bytes wc -l f, wc -w f, wc -c f
Search text grep -rn pattern dir
Find files by name or time find . -name '*.log' -mtime -1
Locate a command which cmd, type cmd
Compare files diff -u a b

Text processing

Task Command
Sort, unique sort f, sort -u f, sort -n f
Count duplicates sort f | uniq -c
Select columns cut -d, -f1,3 f, awk '{print $2}' f
Replace text sed 's/old/new/g' f
Translate characters tr a-z A-Z
Build arguments from input ... | xargs cmd
Show and save at once cmd | tee out.txt

See grep, sed, awk and grep vs sed vs awk.

Permissions and users

Task Command
Change mode chmod 644 f, chmod u+x f, chmod -R g+w dir
Change owner chown user:group f
Who am I, my groups whoami, id, groups
Run as root sudo cmd
Default permissions mask umask

Octal quick table: 7 rwx, 6 rw-, 5 r-x, 4 r--, 0 ---. See Permission bits.

Processes

Task Command
List processes ps aux, ps -ef
Live view top (read-only here)
Find by name pgrep name
Stop politely, forcefully kill PID, kill -9 PID
Run in the background cmd &, then jobs, fg, bg
Survive logout nohup cmd &
Limit run time timeout 10 cmd

Disks and archives

Task Command
Free space per filesystem df -h
Space used by a folder du -sh dir
Block devices, mounts lsblk, mount, findmnt
Memory use free -h
Create, list, extract tar.gz tar czf a.tgz dir, tar tzf a.tgz, tar xzf a.tgz
Compress one file gzip f, gunzip f.gz
Zip zip -r a.zip dir, unzip a.zip

Network

Task Command
Test reachability ping -c 3 host
Download curl -O url, wget url
Addresses and routes ip addr, ip route
Listening ports ss -ltn
DNS lookup dig name, host name
Remote shell, copy ssh user@host, scp f user@host:path

Most network commands need a real network and are read-only here.

System and services

Task Command
Kernel and OS uname -a, cat /etc/os-release
Uptime and load uptime
Service control systemctl status|start|stop|restart name
Logs journalctl -u name -e, dmesg | tail
Date and time date, date +%F
Install (Debian, Fedora) apt install pkg, dnf install pkg

Bash shortcuts

Keys Action
Ctrl+C Interrupt the running command
Ctrl+D End input / log out
Ctrl+Z Suspend the job
Ctrl+R Search command history
Ctrl+A / Ctrl+E Start / end of line
Ctrl+W Delete the previous word
!! Repeat the last command
!$ Last argument of the previous command
Tab Complete names

Usage notes

  • Dangerous commands first. rm -r, chmod -R, chown -R, dd and mkfs act without confirmation. Check the path twice and prefer ls or echo first.
  • Options vary by system. This sheet assumes GNU tools as on most Linux distributions; BSD and macOS differ in flags such as sed -i and ls --color.
  • Combine short options (ls -lah) and use -- before names that may start with a dash.
  • Quote patterns passed to find, grep and sed so the shell does not expand them first.
  • Ask the system. man, --help and apropos keyword document what is actually installed. See man.