One line commands – one-liner

May 8, 2018 by No Comments

One line commands – one-liner

One line commands or one-liner is a group of commands executed in one line to accomplish some tasks. One-liners will be time saver for the system admins in his day to day life.  In order to understand and generate one-liners the tech needs to understand all the commands and its functionalities in detail.

Basic idea of one-liner

Passing the out put of a command to the second command and it to next line. Finally the output is filtered or modified to get a meaningful output. Some of the examples for one-liners are mentioned here

netstat -plan | grep :80  | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nk1

Above command will give the sorted list of IP’s with number of connections to the port 80.

If you know more one-liners, please comment here. Also you can contact me for explaining these one-liners or new one which is not understand by you. If you are a system admin who likes to make more one-liners to ease the work, you should learn commands in detail. In my opinion, learn 3 commands per week ( 2 day for one command ). So you have enough time for checking detail about each command and you can dig the unknown areas of the command options. If you follow these, you will learn 12 command per month and after few months, you will learn almost all the commands and you can restart the process with the same commands again. This time, you will learn more options which are missed in the first round. This helps to make one-liners and to make bash scripts for doing the administration tasks.