What Are Your Favorite Command Line Hidden Gems?

rpalo profile image Ryan Palo ・1 min read

I just found out about gpp, which is a neat text preprocessor for quick and low-power templating. Which sparked me to look for other commands that are super cool but might not show up in the beginner tutorials.

So here it is: what are your favorite commands that might not be as popular? Bonus points if they come pre-packaged on your favorite OS. Big bonus if you don’t have to install them with a language-specific package manager like pop, gem, or npm—not because there’s anything wrong with u them. I’m just trying to steer this away from a pile of “just npm install kitchen-sink-robot-suit!”


Editor guide
io_io_rocks profile image

I am on Linux since 2005 and here's one of the most often used things:
I do CTRL + R to get the reverse CLI history, then I just type the first characters from: find . -type f -name ".*.sw*" -exec rm -f {} \;, find it then hit Enter.
It finds all the .swp, swo, etc files left from my vim sessions and deletes them.
Also, big lol @ npm install kitchen-sink-robot-suit :-))
That name surely needs a package!

fcfn profile image
Peter Timoshevsky

You can also use the specific -delete action with find.

io_io_rocks profile image

Good to know, thank you!

wrldwzrd89 profile image
Eric Ahnell

My favorite command I often forget about is tee - used for simultaneously writing to the terminal AND to a file. It works best as part of a pipeline, which makes it a good fit for any shell supporting them - pretty much all the modern shells do now. I like to use this for verification: Did what my shell script print out match what I expect it to?

jbeetz profile image
J Beetz

It's not so much of a command but rather the concept of the | symbol. The pipe symbol is pretty a universal concept.

I use it in Powershell commands and Linux commands.
This Linux command gets a lot of use:
ps -ef | grep <'any string here'>
history | grep <'whatever command I think I just ran'>

vguarnaccia profile image
Vincent Guarnaccia

curl -vvv is helpful for learning and experimenting with all things http related.

Not exactly a command, but favorite bad habit is running processes in the background with slow_cmd &.

rpalo profile image
Ryan Palo Author

The more I learn about curl, the more it blows my mind how powerful it really is.

With regards to backgrounding commands, I know about the ability, but I've never had an instance where I've thought to do it. What kind of commands do you find yourself backgrounding?

vguarnaccia profile image
Vincent Guarnaccia

Mostly I background update commands when I first login. Definitely not a good habit but I always read the stdout.

flatpak update $
yay &
brew update &

chanduthedev profile image

file command to know file format. Some times file name may contains wrong extension or doesn't contain extension. In this case file command really helps to know the format of the file. Below is the syntax.

file file_name

And below are some of results for file command.

"ASCII text" - normal text file
"ASCII text, with very long lines" - CSV file with large lines
"Zip archive data, at least v4.5 to extract" - ZIP file

molly_struve profile image
Molly Struve (she/her)

One of my favorites is an oldie but goodie, the table_print gem.

It allows you to print arrays of data out in nice tables