HeadlinesBriefing favicon HeadlinesBriefing.com

Shell Tricks That Actually Make Life Easier

Hacker News •
×

There is a distinct, visceral kind of pain in watching an otherwise brilliant engineer hold down the Backspace key for six continuous seconds to fix a typo at the beginning of a line. We’ve all been there. We learn ls, cd, and grep, and then we sort of… stop. The terminal becomes a place we live in-but we rarely bother to arrange the furniture. We accept that certain tasks take forty keystrokes, completely unaware that the shell authors solved our exact frustration sometime in 1989.

The ‘Works (Almost) Everywhere’ Club These tricks rely on standard terminal line disciplines, generic Bourne shell behaviors, or POSIX features. If you SSH into an embedded router from 2009, a fresh OpenBSD box, or a minimal Alpine container, these will still have your back. The Backspace Replacements Why shuffle character-by-character when you can teleport? These are standard Emacs-style line-editing bindings (via Readline or similar), enabled by default in most modern shells. CTRL + W: You’re typing /var/log/nginx/ but you actually meant /var/log/apache2/. You have two choices: hold down Backspace until your soul leaves your body, or hit CTRL + W to instantly delete the word before the cursor. Once you get used to this, holding Backspace feels like digging a hole with a spoon.

If you’re on a Linux box or using a modern interactive shell, these are the tools that make the CLI feel less like a rusty bicycle and more like something that actually responds when you steer. The History Hunter CTRL + R: Reverse incremental search. Stop pressing the up arrow forty times to find that one awk command you used last Tuesday. Press CTRL + R, start typing a keyword from the command, and it magically pulls it from your history. The “Oops, Sudo” Move!!: This expands to the entirety of your previous command. Its most famous use case is the “Permission denied” walk of shame. You confidently type systemctl restart nginx, hit enter, and the system laughs at your lack of privileges. Instead of retyping it, run: It’s your way of telling the shell, “Do what I said, but this time with authority.”

The summary ends with a concrete statement about the value of these tools for terminal efficiency and script robustness.