Mastering the various terminal commands is a must for everybody
The Linux Terminal is a very powerful tool and it’s most probably the most interesting part of Unix. There are a plethora of commands that can help us in our day-to-day life.
I am a software engineer in Silicon Valley, with over 12 years of experience. And I am totally in love with Linux. I consistently use these commands in my everyday life. Knowing some of these utility Linux commands off the back of my mind, has surely made my life a lot easier.
From a developer to a QA to a sysadmin, everyone should have a good grasp of these Linux commands. It will surely help you in some way or the other.
If you have a slow ‘Google Chrome’ and want to kill all running and open chrome instances, or if you have a Notes app that is not responding, killall is an easy command that can help you.
Killall exactly matches the argument name by default and kills the matching process. Here is how to use it
But remember that this command will not let the application save any data, so you may lose data if you have not saved it.
By default, the killall command is case-sensitive. But you can use the -I option to ignore the case.
killall -I notes
You can get more details here.
Ctrl + x + e
If you want to write a long command, but you do not want to type it on your terminal for many obvious reasons, this shortcut will help.
Ctrl + x + e will open an editor where you can type your command. And upon saving the editor, the command will run on the terminal
The editor that opens is known as Emacs. Emacs or EMACS is a family of text editors that are characterized by their extensibility.
Some installations may not have the emacs readily available. You can download by running the following command
brew cask install emacs
The most basic use of this command is to create an empty file.
The above will create an empty file. You can also create a bunch of files if needed.
You can use this to change the timestamp of your file. And this is one command I used a lot to hide some edits that I may have done by mistake when starting off my IT life <wink>.
You can be innovative and copy the timestamp from another file as well.
touch -r file_name2 file_name1
Do a ‘man touch’ to find out more about the command.
tee command in UNIX is a command-line utility for copying standard input to standard output. It supports writing whatever it is given from standard input to standard output and optional writing to one or more files. That’s especially helpful when you want to redirect data to a file as well as see what’s in the file.
The command is named after the T splitter used in plumbing.
This is how we can use the command.
Suppose you want to edit a really long command that you just fired. Using the terminal will need some effort. The ‘fc’ command solves this problem.
In the below example, I ran a curl command that had a typo. So I ran the fc command. The previous command — curl opened in an editor; I fixed the command and saved the file. And the curl command ran again with the results
This is a bonus command.
If you want to relieve the pressure after some hard hours at work, or you just want to stare at something else, ‘sl’ is the command for you. Linux can be funny at times!!
This is how you install ‘sl’
brew install sl
Then let’s join the party.
Try and type ‘sl’ in the terminal and see what happens. For those who first want to see it before trying it out themselves, here is a screenshot:
Now type ‘sl -F’ and see it fly.
I believe, no matter whether you’re a seasoned Linux user like me or a beginner who’s just starting to get his feet wet in this fantastic world of Unix systems, mastering the various terminal commands is a must for everybody.
And I hope you all learned something new today. Share your fancy Linux commands in the comments section.