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.
pushd and popd
— Bruised thumb (@danclark) May 2, 2020
I really want to go to that other directory, but I don't want to lose my current one.
pushd /the/new/path
Then when you're done popd to return.
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.
tail -f somelogfile.log
— Bruised thumb (@danclark) May 2, 2020
Run this in a separate terminal then start up whatever is blowing up on you. It will show you the log as it's written. If there are multiple logs you can Ctrl-z and then bg the multiple files. Then you'll see the output from all as they happen.
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
Sorry the summary didn't render properlyMay 2, 2020
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.
Also checkout vim. It's SCARY what it can do. I've also heard the same of awk and sed, but I need to find time to learn those.
— Bruised thumb (@danclark) May 2, 2020
vim: the text editor that started the first holy war with emacs
sed: can alter text in a number of ways.
awk: I hate that I don't know what this does
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...
Oh I love less. Anytime I need to look at a file I just less that /allows me to search the file. It's like vim!
— Bruised thumb (@danclark) May 2, 2020
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.
git grep -i "that &%Ʃ! thing you're looking for"
— Bruised thumb (@danclark) May 2, 2020
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.
sorry tweet doesn't renderMay 2, 2020
time
How long did that take again? Is it getting faster? Slower? A tip by @schiefewelt
time <your command>, runs a command and measures how long it took.
— Umut Topuzoğlu (@schiefewelt) May 2, 2020
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
— Bartosz Gordon (@xbgord) May 2, 2020
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
Maybe not a command, but search for a command. It was a game changer when I’ve found out about it.
— Telmo (@telmo) May 2, 2020
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.
sigh the summary didn't render again May 2, 2020
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.
sorry the summary didn't renderMay 2, 2020