What’s your favorite lesser known terminal utility/command? 2020/5/2 edition

Here's a round up of all the neat stuff that was posted under @tlakomy's tweet on lesser known utilities/commands. Enjoy!!!

And don’t run random commands from Twitter in your terminal before making sure it does what you think it does. You can use explainshell.com to learn a little bit first before you endanger your system. YES AN ASSHAT TRIED TO SUGGEST rm -rf IN ROOT. Don't do that. Be especially wary of anything that starts with sudo.

pushd and popd

Let's say you're in the middle of something and you spot a rabbit hole you want to dig into, but you don't want to lose where you are. Fear not! You can use pushd to go to the new directory and then popd will return you back once you're done. This is nice when cd - just won't cut it.

tail -f somelogfile.log

Are you struggling with a problem and you want to see the logs. tail -f the_log_in_question.log is here to save the day! If you're dealing with more files you can run multiple instances of tail -f Simply do something like this

dan@bruisedthumb:~$ tail -fn0 test.log
^Z
[3]+  Stopped                 tail -fn0 test.log
dan@bruisedthumb:~$ bg
[3]+ tail -fn0 test.log &
dan@bruisedthumb:~$ tail -fn0 test2.log
^Z
[4]+  Stopped                 tail -fn0 test2.log
dan@bruisedthumb:~$ bg
[4]+ tail -fn0 test2.log &
dan@bruisedthumb:~$ 

Here we use ctrl-z to stop each tail and bg to put that process in the background. So when a line gets written to either one it shows up in your console.

find / -name SOMETHING 2> /dev/null

@_marcba dropped this tip. Per @gheorghitahrmz it will find something and all errors are sent to /dev/null (hidden). Display only found files/directory

vim, sed, and awk

vim is scary powerful, and its fanatics are having regularly holy wars with emacs fanatics (well users of any other text editor really). Also sed and awk are cool too.

I love less

It's like vim but not. Also / searches the contents. Also you'd never know that english is the only language I know...

git grep -i "that &%Ʃ! thing you're looking for"

Can't find something in your project? This searches your git repo for that thing. The -i is case insensitive.

The tee command

A tip by @ol_lebowski This is used in conjunction with pipes. As pipe tee will elevate to sudo permissions.

time

How long did that take again? Is it getting faster? Slower? A tip by @schiefewelt

rupa/z

Here's a suggested repo by @xbgord. Warning I have not tested or looked too hard at this yet so be careful, but the description sounds really really really neat

CTRL + R all the things!!!

A few people dropped this one (@telmo, @gheorghitahrmz, liran_tal,danielrvt). This will allow you to search your command history

CMD-K to clear the screen

I'll have to try this out on my mac later, but sudo_overflow drops a hint on keeping your terminal tidy.

CTRL + P and CTRL + Z

As a vim user I respect anyone who doesn't use the arrow keys. Thanks to tweet_rchase for this tip.

Back