Skip to content
Linux Commands Cheatsheet — Essential Reference

Linux Commands Cheatsheet — Essential Reference

DodaTech 3 min read

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

File Operations

CommandWhat it does
ls -laList files (detailed, hidden)
cp -r src dstCopy recursively
mv src dstMove or rename
rm -rf dirRemove recursively, force
touch fileCreate empty file or update timestamp
cat filePrint file content
less fileScroll through file (q to quit)
head -n 5 fileFirst 5 lines
tail -f fileFollow log in real time
mkdir -p a/b/cCreate 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

CommandWhat it does
ps auxAll running processes
top / htopInteractive process viewer
kill -9 PIDForce kill process
pkill nginxKill by name
jobsList background jobs
fg %1Bring job to foreground
command &Run in background
nohup command &Run immune to hup

Networking

CommandWhat it does
ping 8.8.8.8Test connectivity
curl -s example.comHTTP request
wget urlDownload file
ssh user@hostSSH connection
netstat -tulpnListening ports
ss -tulpnModern alternative
ip a / ifconfigNetwork interfaces
scp file user@host:/pathSecure copy

Package Management

DistroCommand
Debian/Ubuntuapt update && apt install pkg
RHEL/Fedoradnf install pkg
Archpacman -S pkg
macOSbrew 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

CommandExtWhat it does
tar czf archive.tar.gz dir/.tar.gzCompress
tar xzf archive.tar.gz.tar.gzExtract
zip -r archive.zip dir/.zipCompress
unzip archive.zip.zipExtract
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