Linux Command Line: The Developer's Survival Guide (2026)
The terminal is your superpower. These are the commands and patterns I use every single day as a developer.
File System Navigation
# === Essential navigation ===
pwd # Where am I?
ls -la # List all files with details (permissions, sizes, dates)
ls -laht # Same but sorted by time (newest first)
cd ~ # Go home
cd - # Go to previous directory
# === Finding things ===
find . -name "*.js" # Find JS files in current directory (recursive)
find . -name "*.js" -mtime -7 # Modified in last 7 days
find . -type d -name "node_modules" -exec rm -rf {} + # Delete all node_modules dirs!
# Faster alternative for file search:
fd ".js" # Much faster than find, ignores .gitignore by default
fd "test" src/ # Search only in src/
# === File content search ===
grep -r "TODO" . # Search recursively for text
grep -rn "function" src/ # With line numbers, only in src/
grep -rn --include="*.ts" "interface" src/ # Only TypeScript files
# Faster alternative:
rg "function" src/ # ripgrep — blazing fast, respects .gitignore
rg -i "error" --type js # Case-insensitive, JS files only
rg "TODO|FIXME|HACK" # Regex search
# === Directory tree view ===
tree -L 2 # Show 2 levels deep
tree -L 2 -I 'node_modules|.git' # Exclude common junk
File Operations You Actually Need
# === Viewing files ===
cat file.txt # Print entire file
less file.txt # Scrollable viewer (q to quit, / to search)
head -n 20 file.txt # First 20 lines
tail -n 20 file.txt # Last 20 lines
tail -f app.log # Follow log file in real-time (Ctrl+C to exit)
# bat = cat with syntax highlighting (install: apt install bat or brew install bat)
bat app.js # Colorized, line-numbered, git-integrated output
# === Creating & editing ===
touch newfile.js # Create empty file (or update timestamp)
mkdir -p project/src/{components,hooks,utils} # Nested directories (-p creates parents)
cp source.js dest.js # Copy
cp -r folder/ backup/ # Copy directory (recursive)
mv oldname newname # Rename/move
rm file.txt # Delete (⚠️ gone forever!)
rm -rf folder/ # Delete directory and contents (⚠️ dangerous!)
# Safe delete alternatives:
trash file.txt # Move to trash (recoverable! install: pip install trash-cli)
# Or alias rm='rm -i' (prompts before each deletion)
# === Disk usage ===
du -sh * # Size of each item in current directory
du -sh */ | sort -hr # Sorted by size (largest first)
df -h # Disk space overview (free vs used)
# Find large files:
find . -type f -size +50M # Files larger than 50MB
du -ah . | sort -rh | head -10 # Top 10 largest items
# === Quick file stats ===
wc -l file.txt # Line count
wc -w file.txt # Word count
stat file.txt # Full metadata (permissions, timestamps, inode)
Process Management
# === Finding processes ===
ps aux | grep node # Find Node processes
ps aux --sort=-%mem | head # Processes sorted by memory usage (top consumers)
# Modern alternative:
htop # Interactive process viewer (install: apt install htop)
# Press F6 to sort, F9 to kill, / to search
# === Killing processes ===
kill <PID> # Graceful termination (SIGTERM)
kill -9 <PID> # Force kill (SIGKILL) — use as last resort
pkill -f "node server.js" # Kill by name/pattern
killall node # Kill ALL processes named 'node' (be careful!)
# Port finder: what's running on port 3000?
lsof -i :3000 # Shows process using port 3000
ss -tlnp | grep 3000 # Alternative (faster, no root needed sometimes)
fuser 3000/tcp # Another option
# Kill whatever is on port 3000:
kill $(lsof -t -i :3000) # Get PID from lsof, pass to kill
# === Background jobs ===
node server.js & # Run in background
jobs # List background jobs
fg %1 # Bring job 1 to foreground
Ctrl+Z # Suspend current job (pause it)
bg # Resume suspended job in background
nohup node server.js > app.log 2>&1 & # Survives after you close terminal
# === System resources ===
free -h # Memory usage
uptime # Load averages + uptime
top # Real-time process monitor (q to quit)
vmstat 1 # Memory/CPU stats every second
iotop # Disk I/O by process (need sudo)
Networking Essentials
# === Connection testing ===
ping google.com # Basic connectivity
curl -I https://example.com # HTTP headers only (check if site is up)
curl -v https://api.example.com/test # Verbose (see full request/response)
wget https://example.com/file.zip # Download file
# Debug HTTP APIs:
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token123" \
-d '{"name": "Alice", "email": "alice@example.com"}'
# Follow redirects, show timing:
curl -o /dev/null -s -w "%{http_code} %{time_total}s\n" https://example.com
# === DNS ===
nslookup example.com # DNS lookup
dig example.com # More detailed DNS info
host example.com # Simple lookup
# === Port scanning (quick check) ===
nc -zv localhost 3000 # Is port 3000 open? (netcat)
ss -tlnp # All listening ports
# === Network info ===
ip addr # Your IP addresses (modern, replaces ifconfig)
ip route # Routing table
curl ifconfig.me # Public IP address
curl ipinfo.io # Public IP + location info
Text Processing Power Tools
# === sed — stream editor (find & replace in files) ===
sed -i 's/old/new/g' file.txt # Replace all occurrences in file
sed -i 's/foo/bar/g; s/baz/qux/g' file.txt # Multiple replacements
sed -n '10,20p' file.txt # Print lines 10-20
sed -i '/^$/d' file.txt # Delete empty lines
# === awk — text processing language ===
awk '{print $1}' file.txt # Print first column
awk -F',' '{print $2}' csv.csv # Second column (comma-separated)
awk '{sum += $NF} END {print sum}' numbers.txt # Sum of last column
awk 'NR >= 5 && NR <= 15' file.txt # Lines 5-15
# Practical: extract IP addresses from nginx access logs:
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
# === sort & uniq ===
sort file.txt # Sort lines alphabetically
sort -rn numbers.txt # Sort numerically (descending)
uniq file.txt # Remove adjacent duplicates
sort file.txt | uniq -c # Count occurrences
sort file.txt | uniq -c | sort -rn | head # Most frequent items
# === xargs — build command lines from input ===
find . -name "*.log" | xargs rm # Delete all .log files
find . -name "*.js" | xargs wc -l # Line count of all JS files
cat urls.txt | xargs -I{} curl -s {} # Run curl for each URL
# Parallel execution with xargs:
cat urls.txt | xargs -P4 -I{} curl -s {} # 4 parallel curl requests!
SSH & Remote Development
# === Basic connection ===
ssh user@server.example.com
ssh user@192.168.1.100
ssh -p 2222 user@server # Custom port
# === Key-based auth (no passwords!) ===
ssh-keygen -t ed25519 -C "my-key"
ssh-copy-id user@server # Copy public key to remote server
# Now: ssh user@server (no password needed!)
# === Tunnels (expose local services remotely) ===
ssh -L 8080:localhost:3000 user@server # Forward local 8080 → remote's localhost:3000
ssh -R 8080:localhost:3000 user@server # Forward remote's 8080 → your localhost:3000
# === SCP: copy files over SSH ===
scp file.txt user@server:/path/to/dest/ # Upload
scp user@server:/path/to/file.txt ./ # Download
scp -r folder/ user@server:/path/ # Upload directory
# Better alternative: rsync (resumable, shows progress!)
rsync -avz ./project/ user@server:/opt/project/
rsync -avz --progress ./large-file user@server:/data/
# === Config shortcuts (~/.ssh/config) ===
Host myserver
HostName 192.168.1.100
User deployer
Port 2222
IdentityFile ~/.ssh/id_ed25519
# Now just use: ssh myserver
Developer-Specific Shortcuts
# === Git shortcuts ===
gst → git status
gco → git checkout
gcb → git checkout -b
gp → git push
gl → git pull --rebase
gcmsg → git commit -m
gaa → git add --all
# Add these to your shell config (.bashrc/.zshrc):
alias gst='git status'
alias gco='git checkout'
alias gcb='git checkout -b'
alias gp='git push'
alias gl='git pull --rebase'
alias gcmsg='git commit -m'
alias gaa='git add --all'
alias gpom='git push origin main'
alias grhh='git reset --hard HEAD@{1}'
# === NPM/Yarn/Pnpm shortcuts ===
ni → npm install / pnpm install
nr → npm run / pnpm run
nu → npm update / pnpm update
nx → npm exec / pnpm exec
# === Docker shortcuts ===
dcu → docker compose up -d
dcd → docker compose down
dcl → docker compose logs -f
dce → docker compose exec
# === Quick dev server (Python) ===
python3 -m http.server 8000 # Serve current directory on port 8000
# === JSON pretty-print ===
echo '{"key":"value"}' | python3 -m json.tool
jq '.' response.json # If jq is installed (faster, more features)
# === Base64 encode/decode ===
echo "hello" | base64 # Encode
echo "aGVsbG8K" | base64 -d # Decode
# === Generate random strings ===
openssl rand -hex 16 # Random hex string
date +%s # Unix timestamp
uuidgen # UUID v4
What's your most-used terminal command that wasn't on this list? What CLI tool changed your workflow?
Follow @armorbreak for more practical developer guides.
Top comments (0)