These arenβt obscure commands nobody uses. These are the ones that make people say βwait, how did you do that?β
1. !! β Repeat the last command
apt install [nginx](/blog/nginx-config-generator/)
# Permission denied
sudo !!
# Runs: sudo apt install nginx
!! expands to your last command. sudo !! is the most useful two-word combination in terminal history.
2. ctrl+r β Search command history
Press ctrl+r and start typing. It searches your entire command history. Press ctrl+r again to cycle through matches.
Looking for that Docker command you ran last Tuesday? ctrl+r then type docker β itβs there.
3. xargs β Turn output into arguments
# Delete all .log files
find . -name "*.log" | xargs rm
# Kill all node processes
ps aux | grep node | awk '{print $2}' | xargs kill
# Download a list of URLs
cat urls.txt | xargs -I {} curl -O {}
4. watch β Repeat a command every N seconds
# Monitor disk usage every 2 seconds
watch -n 2 df -h
# Watch pods restart in real-time
watch kubectl get pods
# Monitor a log file's line count
watch wc -l /var/log/app.log
Like a live dashboard in your terminal.
5. column -t β Align output into columns
# Messy output:
cat data.csv
name,age,city
alice,30,brussels
bob,25,amsterdam
# Clean output:
cat data.csv | column -t -s ','
name age city
alice 30 brussels
bob 25 amsterdam
6. tee β Write to file AND stdout
# Save output to file while still seeing it
npm run build 2>&1 | tee build.log
# Append to file
echo "new entry" | tee -a log.txt
Perfect for logging a commandβs output without losing the live view.
7. rsync β Smart file copying
# Copy files to server (only changed files, with progress)
rsync -avz --progress ./dist/ user@server:/var/www/app/
# Local backup with progress
rsync -avh --progress ~/projects/ /backup/projects/
Unlike scp, rsync only transfers changed bytes. Resumable, fast, and shows progress.
8. jq β Parse JSON like a pro
# Pretty-print JSON
curl api.example.com | jq .
# Extract specific fields
curl api.example.com/users | jq '.[].name'
# Filter
curl api.example.com/users | jq '.[] | select(.age > 25)'
# Count items
curl api.example.com/users | jq length
Bonus: Key combos most people donβt know
ctrl+aβ Jump to start of linectrl+eβ Jump to end of linectrl+wβ Delete word before cursorctrl+uβ Delete entire line before cursorctrl+kβ Delete from cursor to end of linealt+.β Insert last argument of previous command
These work in bash, zsh, and most terminals. Learn them once, use them forever.
Related: Bash Cheat Sheet β the complete reference for everything bash.