DEV Community

7 Terminal Commands Every Developer Should Know (But Most Don't)

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Kill all processes matching a name:

ps aux | grep node | awk '{print $2}' | xargs kill
Enter fullscreen mode Exit fullscreen mode

4. watch — Run a Command Repeatedly

Monitor a directory for changes every 2 seconds:

watch -n 2 ls -la /tmp/builds/
Enter fullscreen mode Exit fullscreen mode

Watch your API respond in real-time:

watch -n 1 'curl -s localhost:3000/health | jq .'
Enter fullscreen mode Exit fullscreen mode

5. tee — Write to File AND Terminal

See output while also saving it:

npm run build 2>&1 | tee build.log
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode
  • -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 ','
Enter fullscreen mode Exit fullscreen mode

Before:

name,age,city
john,25,NYC
jane,30,LA
Enter fullscreen mode Exit fullscreen mode

After:

name  age  city
john  25   NYC
jane  30   LA
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)