ABHIJAT
← Back to Writing

Systems

The Bash one-liners I actually use daily

Not a reference list of every possible flag. Just the handful that earn a spot in muscle memory.

Abhijat2026-083 min read6 views

Last updated September 17, 2026

Most Bash reference lists are exhaustive and forgettable. This is the opposite — just the handful of one-liners that have actually stuck, because they solve a problem that comes up often enough to be worth remembering.

What's actually eating disk space

du -h --max-depth=1 | sort -rh

du -h alone is too much output for anything but a tiny directory tree. Capping the depth and sorting by size, largest first, turns it into an actual answer instead of a wall of numbers to scan through.

Grepping ps without matching yourself

ps aux | grep '[n]ode'

The bracket trick around the first letter is the part worth remembering: grep '[n]ode' matches node in the process list but doesn't match the literal string grep [n]ode that's running the search itself, which is a cleaner fix than the more common | grep node | grep -v grep.

Rerunning the last command with sudo

sudo !!

For the specific, recurring mistake of running a command, getting a permissions error, and needing to rerun it with sudo — this reruns the previous command with sudo prepended, no retyping required.

Watching a log and filtering it live

tail -f app.log | grep --line-buffered ERROR

tail -f alone shows everything; piping through grep filters it down to what actually matters. The --line-buffered flag is the part that's easy to forget and breaks the whole thing without it — without it, grep's output buffering can delay matching lines from appearing until enough output has accumulated, which defeats the point of watching a log in real time.

None of these are exotic. That's the point — the ones that stick around in daily use are the ones that solve a genuinely recurring annoyance, not the ones that are cleverest.

Tags

BashLinuxProductivity