Skip to content

Linux Commands Cheatsheet — Essential Reference

DodaTech 3 min read

In this tutorial, you'll learn about Linux Commands Cheatsheet. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Essential Linux commands for file management, permissions, processes, networking, text processing, and package management — a sysadmin's daily reference.

File Operations

Command What it does
ls -la List files (detailed, hidden)
cp -r src dst Copy recursively
mv src dst Move or rename
rm -rf dir Remove recursively, force
touch file Create empty file or update timestamp
cat file Print file content
less file Scroll through file (q to quit)
head -n 5 file First 5 lines
tail -f file Follow log in real time
mkdir -p a/b/c Create nested directories

Permissions

chmod 755 script.sh          # rwxr-xr-x
chmod u+x script.sh          # add execute for user
chown user:group file        # change owner/group
chown -R user:group dir/     # recursive

Permission modes: r=4, w=2, x=1chmod 644 = rw-r--r--

Processes

Command What it does
ps aux All running processes
top / htop Interactive Process viewer
kill -9 PID Force kill Process
pkill nginx Kill by name
jobs List Background Jobs
fg %1 Bring job to foreground
command & Run in background
nohup command & Run immune to hup

Networking

Command What it does
ping 8.8.8.8 Test connectivity
curl -s example.com HTTP request
wget url Download file
ssh user@host SSH connection
netstat -tulpn Listening ports
ss -tulpn Modern alternative
ip a / ifconfig Network interfaces
scp file user@host:/path Secure copy

Package Management

Distro Command
Debian/Ubuntu apt update && apt install pkg
RHEL/Fedora dnf install pkg
Arch pacman -S pkg
macOS brew install pkg

Text Processing

grep -r "error" /var/log/          # recursive search
grep -i "warning" log.txt           # case-insensitive
grep -v "^#" config.conf            # exclude comments

find /home -name "*.py"             # find by name
find . -type f -size +10M           # find by size

sort file.txt                       # sort lines
wc -l file.txt                      # count lines
uniq -c file.txt                    # count unique lines

sed & awk

sed 's/old/new/g' file.txt          # replace all
sed -i '.bak' 's/old/new/g' file    # in-place with backup

awk '{print $1, $3}' file.txt       # print columns
awk '/error/ {print $0}' log.txt    # filter + print
awk '{sum+=$1} END {print sum}' nums.txt  # sum column

Compression

Command Ext What it does
tar czf archive.tar.gz dir/ .tar.gz Compress
tar xzf archive.tar.gz .tar.gz Extract
zip -r archive.zip dir/ .zip Compress
unzip archive.zip .zip Extract
What is the difference between `kill`, `kill -9`, and `pkill`?

kill PID sends SIGTERM (15) — allows graceful shutdown. kill -9 PID sends SIGKILL — forces immediate termination, Process cannot clean up. pkill name kills by Process name (matches any Process containing the string). Try kill first, then kill -9 if the Process ignores it.

How do I search for a file by name in Linux?

Use find: find /path -name "filename". For case-insensitive search: find /path -iname "filename". Use -type f for files only, -type d for directories. The locate command is faster (uses a pre-built database) but less up-to-date: locate filename.

What is the difference between `curl` and `wget`?

curl is a tool for transferring data with URLs, supporting many protocols. It outputs to stdout by default and is great for API testing. wget is a download tool — it recursively downloads, resumes interrupted downloads, and saves to files by default. Both can download files, but wget is better for bulk downloads and curl for API work

See the full Linux administration guides for more.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro