Linux Basic Commands: A Practical Cheat Sheet for Beginners

By · · Updated

Copy-paste recipes with safety notes. When in doubt, read the manual: man <tool>.

2) Files & Directories

Create, copy, move, and remove—safely.

# create files and directories
touch notes.txt
mkdir -p src/components

# copy (file → file, or into dir)
cp file.txt backup.txt
cp file.txt docs/

# move / rename
mv README.md README.old.md
mv *.log logs/

# remove (prompt before delete)
rm -i file.txt
rm -rI old_project/   # 'I' prompts once if many files

# safer delete: send to trash if you have 'trash-cli'
trash-put file.txt

⚠️ Danger zone: rm -rf / or a bad wildcard can wipe systems. Prefer rm -rI (capital i) to get a one-time bulk prompt.

For deeper control over ownership and modes, read Linux File Permissions.

3) View & Edit Text

Peek at files without opening a full editor.

# print entire file or concatenate
cat notes.txt

# first / last lines
head -n 20 access.log
tail -n 50 access.log
tail -f /var/log/syslog      # follow updates

# page through with navigation
less bigfile.txt             # /pattern to search, q to quit

# quick edits (nano is beginner-friendly)
nano notes.txt

5) Permissions & Ownership

Know who can read/write/execute—and how to change it.

# show long listing with modes and owners
ls -l

# change permission (symbolic)
chmod u+rw,go-r file.txt

# change permission (octal: rwx = 7, rw- = 6, r-x = 5, r-- = 4)
chmod 644 file.txt
chmod 755 scripts/run.sh

# change owner / group (requires sudo)
sudo chown mason:mason file.txt

# add execute bit to a script
chmod +x deploy.sh

New to modes and sticky bits? Walk through examples in Linux File Permissions.

6) Processes & Jobs

# list processes (wide + tree)
ps aux | less
pstree -p | less

# top / htop for live view (install 'htop' first)
top
htop

# kill by PID or by name (gently, then force)
kill 12345
pkill -f "node server"
kill -9 12345   # SIGKILL (last resort)
# run jobs in background / bring to foreground
sleep 60 &        # background
jobs
fg %1             # bring job 1 to foreground
Ctrl+Z            # suspend current job
bg %1             # resume in background

System health & metrics: see System Monitoring.

7) Networking Basics

# show interfaces and addresses
ip a

# check DNS / reachability
ping -c 4 example.com
dig example.com +short
nslookup example.com

# open ports (requires 'ss' or 'netstat' pkg)
ss -tulpn | less   # listening sockets
curl -I https://example.com   # HTTP headers

More commands (SSH, traceroute, firewall) live in Linux Networking.

8) Packages (Install, Update, Remove)

Debian/Ubuntu (APT)

sudo apt update
sudo apt upgrade
sudo apt install <pkg>
apt search <term>
apt show <pkg>
sudo apt remove <pkg>
sudo apt autoremove

See Debian’s docs: Apt and AptCLI.

Arch (pacman)

sudo pacman -Syu             # sync + full upgrade
sudo pacman -S <pkg>
sudo pacman -Rns <pkg>
pacman -Ss <term>
pacman -Qi <pkg>

Reference: Arch Wiki – Pacman.

Package archives & tarballs explained here: Working with Tarballs and Package Management.

9) Compression & Archiving

# create a gzipped tar archive
tar -czf site-backup.tgz /var/www/site

# extract into current directory
tar -xzf site-backup.tgz

# zip / unzip
zip -r site.zip site/
unzip site.zip -d ./site

10) Disk & System Info

# disk space by filesystem / inode usage
df -h
df -i

# per-dir sizes (top level)
du -h --max-depth=1

# memory / CPU
free -h
lscpu

# OS release and kernel
cat /etc/os-release
uname -a

11) Remote: SSH, SCP & Rsync

# login to a server
ssh user@host

# copy file to server (local → remote)
scp ./backup.tgz user@host:/home/user/

# sync a folder (dry run first!)
rsync -av --dry-run ./public/ user@host:/var/www/site/
rsync -av --delete ./public/ user@host:/var/www/site/

12) Shell Productivity (Pipes, History, Aliases)

# chain commands with pipes
journalctl -u nginx --no-pager | rg "error|warn" -n

# sort / unique with counts
cut -d" " -f1 access.log | sort | uniq -c | sort -nr | head

# history search (press Ctrl+R, then type)
# or grep it explicitly
history | grep ssh

# quick aliases (add to ~/.bashrc or ~/.zshrc)
alias ll='ls -alh'
alias gs='git status'

# variables & export
export EDITOR=nano

When you’re ready, level up with Shell Scripting.

13) Text Processing: cut, sort, uniq, awk, sed

# CSV: 2nd column, unique domains sorted by frequency
cut -d, -f2 emails.csv | sort | uniq -c | sort -nr | head

# replace in-place (create a backup with .bak)
sed -i.bak 's/http:/https:/g' *.html

# extract 1st and 3rd fields where 5th field > 100
awk -F, '$5 > 100 {print $1, $3}' data.csv

See official docs for behavior details: GNU Coreutils Manual.

14) Logs & Troubleshooting

# system log (journald)
sudo journalctl -xe          # recent errors with detail
sudo journalctl -u nginx     # service-specific logs

# grep recent kernel messages
dmesg | tail -50

# who is using a file/port
lsof /var/log/syslog
sudo lsof -i :443

15) Help: man, --help, info

# quick overview
tool --help

# full manual (q to quit, /pattern to search)
man tool
man 1 ls     # specify section

# deeper docs for bash features
info bash

Online references: Linux man-pages · GNU Bash Manual.

Quick Reference (Copy-Paste)

TaskCommand
Find big filesfind . -type f -size +100M -exec ls -lh {} + | sort -k5 -h
Top 10 IPs hitting serverawk '{print $1}' access.log | sort | uniq -c | sort -nr | head
Open portssudo ss -tulpn
Fast text searchrg -n "pattern"
Backup foldertar -czf backup_$(date +%F).tgz ./folder

Next Steps

Keep momentum with these focused deep dives from my Linux series:

Spot an error or a better angle? Tell me and I’ll update the piece. I’ll credit you by name—or keep it anonymous if you prefer. Accuracy > ego.

Portrait of Mason Goulding

Mason Goulding · Founder, Maelstrom Web Services

Builder of fast, hand-coded static sites with SEO baked in. Stack: Eleventy · Vanilla JS · Netlify · Figma

With 10 years of writing expertise and currently pursuing advanced studies in computer science and mathematics, Mason blends human behavior insights with technical execution. His Master’s research at CSU–Sacramento examined how COVID-19 shaped social interactions in academic spaces — see his thesis on Relational Interactions in Digital Spaces During the COVID-19 Pandemic . He applies his unique background and skills to create successful builds for California SMBs.

Every build follows Google’s E-E-A-T standards: scalable, accessible, and future-proof.