Navigation and Files

pwd
Print current directory.
ls -lah
List with details, human-readable sizes, and hidden files.
tree
Show folder tree (may require install).
cd <dir>
Change directory (cd - jumps to previous).
mkdir -p <dir/path>
Create directory (and parents if needed).
touch <file>
Create an empty file or update timestamps.
cp [-r] <src> <dst>
Copy files (-r for directories).
mv <src> <dst>
Move or rename files/directories.
rm <file>
Remove a file (rm -r for directories; be careful with rm -rf).
ln -s <target> <link>
Create a symbolic link.
stat <file>
View detailed file metadata.

Viewing and Editing

cat <file>
Print entire file to stdout.
less <file>
View file with paging and search (/ to search, q to quit).
head -n 20 <file>
Show first 20 lines.
tail -n 20 <file>
Show last 20 lines; tail -f follows new lines (logs).
sed -n '1,20p' <file>
Print a range of lines without opening an editor.
nano <file>
Simple terminal editor.
vim <file>
Powerful modal editor (:q! to quit without saving, :wq to save and quit).

Search and Filters

grep "pattern" <file>
Search for lines containing a pattern.
grep -R "pattern" <dir>
Recursive search in a directory tree.
rg "pattern"
Fast ripgrep search (if installed).
find . -name "*.log"
Find files matching a pattern from current directory down.
find . -type f -mtime -1
Find files modified in the last 24 hours.
xargs -0
Safely pass filenames with spaces (paired with -print0).

Text Processing

sort
Sort lines from stdin (pipe into it).
uniq -c
Collapse adjacent duplicates and count them.
wc -l
Count lines in a file or stream.
cut -d ',' -f 1
Extract the first CSV column.
awk '{print $1}'
Print first column of space-delimited text.
tr -d '\r'
Strip carriage returns from Windows files.

Permissions and Ownership

chmod +x <file>
Make a file executable.
chmod 644 <file>
Set read/write for owner, read-only for group/others (common for files).
chmod 755 <dir>
Owner can read/write/execute; others read/execute (common for dirs).
chown <user>[:group] <path>
Change owner (and optionally group) of file/dir.
chgrp <group> <path>
Change group ownership.
umask 022
Set default permissions for new files.

Processes and System

ps aux
List all processes.
ps aux | grep <name>
Find processes by name.
top
Interactive view of processes and resource usage (q to quit).
htop
Nicer version of top (may require install).
kill <pid>
Send TERM signal to a process.
pkill -f <name>
Kill processes by name pattern.
free -h
Memory usage overview.
df -h
Disk usage by filesystem (human-readable).
du -sh <path>
Total size of a directory or file.
systemctl status <service>
Check a systemd service.
journalctl -u <service> -f
Follow logs for a service.

Networking and Archives

ip a
Show network interfaces and IPs.
ss -tulpn
List listening ports and processes.
ping -c 4 <host>
Check connectivity to a host (4 packets).
curl -I <url>
Fetch only HTTP headers (quick endpoint check).
curl -L -O <url>
Download a file and follow redirects.
ssh <user>@<host>
SSH into a remote host using your default key.
scp <file> <user>@<host>:<path>
Copy a file to a remote host via SSH.
rsync -avz <src> <dst>
Fast file sync with progress and resume.
tar -czf archive.tar.gz <dir>
Create a compressed archive from a directory.
tar -xzf archive.tar.gz
Extract a .tar.gz archive.
zip -r archive.zip <dir>
Create a zip archive.
unzip archive.zip
Extract a zip archive.

Shell Productivity

history
View recent commands.
!!
Repeat the last command.
!$
Reuse the last argument from the previous command.
alias ll='ls -lah'
Create a handy shortcut.
export VAR=value
Set an environment variable.
source ~/.bashrc
Reload your shell config.
which <command>
Locate the executable on your PATH.
type <command>
Show how a command is resolved (alias, function, binary).