Having a reliable toolkit can be very useful in making any job easier. Linux is no different, you need a decent toolkit of commands to rely on in order to get the job done. I find myself using these commands often and they are must-haves for any sysadmin’s toolkit!
First and foremost, this one almost goes without saying but you need to be able to get some tools to add to your repertoire. Package management to the rescue! Depending on which distribution you are working on, there are two main package management frameworks. Debian/Ubuntu land uses apt-get and Red Hat and its derivatives such as Oracle Linux and the soon-to-come Rocky Linux (I am omitting CentOS because they are traitors…more on that here ) use yum. Both apt-get and yum are easy to use and look like this:
apt-get install [package] and
yum install [package].
People say that linux doesn’t have to reboot as much as Windows. Is that true? See for yourself! Uptime lets you see how long your system has been running since the last reboot or shutdown. This one is super easy to use, just open a Terminal and type
uptime . This will not only give you the time your system has been up, but as a bonus it gives you the average cpu load!
You will probably need to edit a configuration file at some point to make some changes. Vim is a great text editor that is easy to use(ish) and very powerful. It is terminal based and supports regex for search and replace! The controls can be daunting at first, but getting to know it is well worth it! The biggest hurdle is that it ahs two modes, edit and command. When you first get into vim you are in command mode and you access commands using the colon (:) character. To enter edit mode, you can most commonly use the letter I (insert). To get a feel for the power of the commands, you could use :set number to enable line numbers, then if you wanted to delete a block of lines (say the next 4), you could just move the cursor to the first one and press 4dd (just type them sequentially) this would tell the editor to operate on the current line plus the next 3 and delete the text.
You should probably be starting some service eventually. Or restarting one. This is where systemctl comes in. This one is pretty straight forward. It’s just
systemctl restart|start|stop [service] . It’s worth mentioning that is something goes wrong you should check on it using
Finally, I will introduce sed. Stream Editor is a powerful tool for manipulating files in bulk using regex. It can be build into a bash script to find/replace/remove/add text to a stream of text such as the contents of a file or any text that is fed to it through Standard Input. There is a lot to go into with this one, so I will not cover it here, but I strongly recommend you look into it and learn to use it if you find yourself configuring text files, it will save you lots of time via scripting automation if you are not already using something like Puppet or Ansible.
What are your Top 5 Linux Tools?