Most developers use the terminal every day but only scratch the surface. Here are 7 commands that saved me hours of work — and you probably aren't using them.
1. !! — Repeat Last Command
Forgot sudo? Don't retype the whole thing:
apt install nginx
# Permission denied
sudo !!
# Runs: sudo apt install nginx
This alone saves me minutes every day.
2. ctrl + r — Reverse Search History
Stop scrolling through your history with the up arrow. Press ctrl + r and start typing. It fuzzy-matches your command history.
# Press ctrl+r, type 'docker'
# Finds: docker compose up -d --build
Press ctrl+r again to cycle through matches.
3. xargs — Turn Output Into Arguments
Find all .log files and delete them:
find . -name '*.log' | xargs rm
Kill all processes matching a name:
ps aux | grep node | awk '{print $2}' | xargs kill
4. watch — Run a Command Repeatedly
Monitor a directory for changes every 2 seconds:
watch -n 2 ls -la /tmp/builds/
Watch your API respond in real-time:
watch -n 1 'curl -s localhost:3000/health | jq .'
5. tee — Write to File AND Terminal
See output while also saving it:
npm run build 2>&1 | tee build.log
No more choosing between watching and logging.
6. comm — Compare Two Sorted Files
Find lines unique to each file:
comm -23 <(sort file1.txt) <(sort file2.txt)
-
-23: Lines only in file1 -
-13: Lines only in file2 -
-12: Lines in both
Perfect for comparing dependency lists, configs, or data sets.
7. column -t — Format Output as a Table
Turn messy output into readable tables:
cat data.csv | column -t -s ','
Before:
name,age,city
john,25,NYC
jane,30,LA
After:
name age city
john 25 NYC
jane 30 LA
Bonus: Command Chaining
Know the difference:
| Operator | Meaning |
|---|---|
&& |
Run next only if previous succeeded |
| `\ | \ |
{% raw %};
|
Run next regardless |
make build && make test && make deploy
# Only deploys if build AND test pass
make build || echo 'Build failed!'
# Shows error message only on failure
What's your favorite terminal trick? Share it below!
Want more developer productivity tips? Check out my resource collection — templates, tools, and guides for working smarter.
Top comments (0)