This guide provides a list of useful tools for Linux system admins. This list doesn't include any complex programs (like Ansible, Puppet) that requires a steep learning curve to setup and use in production. Most of the tools given here are just scripts and are very easy to install and use in real time. If you're a budding Linux/Unix sysadmin who has limited experience, make use of these programs to get the job done easily and quickly. These tools may not be useful all the time, but some of them might help.
Sysadmin-util is a collection of scripts that helps the novice sysadmins and users to perform various tasks.
Sysadmin-util consists of the following scripts:
Let us go ahead and see how to install and use some of these tools with examples.
Install sysadmin-util On Linux
Like I already said, the installation of all tools listed here is trivial. In fact, there is no need to install. Just clone its repository and start using the tools in no time.
$ git clone https://github.com/skx/sysadmin-util.git
The above command will clone all the contents of Sysadmin-util repository in the current directory. Cd into that directory and run any tools of your choice. It's that simple!
Sysadmin-util Provides the following useful tools for Linux system admins
This tool helps you to find how long ago a file or directory was modified in human-readable format.
Make sure you're in sysadmin-util directory:
$ cd sysadmin-util
To find when was a file or directory was modified, just mention its path like below.
$ ./ago <path-to-file/directory>
$ ./ago /home/sk/sysadmin-util/ /home/sk/sysadmin-util/ 23 hours ago
$ ./ago /etc/ /etc/ 3 days ago
As you can see, /home/sk/sysadmin-util is modified 23 hours ago and /etc/ directory is modified 3 days ago.
- How To Monitor File Changes Using fswatch In Linux
- Find And Sort Files Based On Access, Modification Date And Time In Linux
Chronic tool runs a command quietly unless it fails i.e. it runs a command and hide STDOUT and STDERR if it completes successfully. It is useful for cron jobs. Instead of trying to keep the command quiet, and having to deal with mails containing accidental output when it succeeds, and not verbose enough output when it fails, you can just run it verbosely always, and use chronic to hide the successful output.
When creating a new cron job, instead of using the following line;
0 1 * * * backup >/dev/null 2>&1
you can use:
0 1 * * * chronic backup
It converts CIDR blocks into their constituent IP addresses.
$ ./cidr2ip 192.168.225.0/24 192.168.225.0 192.168.225.1 192.168.225.2 192.168.225.3 192.168.225.4 192.168.225.5 [...]
The collapse tool removes blank lines and lines that contains white-space from the given file(s).
$ echo -e "Linux is not an OS.\n It is a Kernel. \n\nGnu/Linux is the OS.\n\n\n\n" | ./collapse Linux is not an OS. It is a Kernel. Gnu/Linux is the OS.
The dupes tool will report the files that are identical. It helps you to find duplicate files that contains same contents recursively via SHA1 hash.
$ ./dupes ./.git/logs/HEAD ./.git/logs/refs/remotes/origin/HEAD ./.git/logs/refs/heads/master
This tool will test whether the given directory is empty or not.
The following example shows whether the given directory /home/sk/ostechnix is empty or not.
$ if ./empty-dir /home/sk/ostechnix; then echo "It is empty" ; fi It is empty
If the directory is not empty, you will not see any output.
This tool expands the given abbreviated/compressed IPv6 addresses to their full-form. It can be useful when setting up DNS entries.
$ ./expand-ipv6 fe80::a00:27ff:feff:d2e0 fe80:0000:0000:0a00:27ff:feff:d2e0
It is a multi-protocol ping wrapper. It is used to test the connectivity of a remote host, regardless of whether it is an IPv6 or IPv4 host. Meaning - if the remote uses IPv4, it invokes 'ping' command to test the connectivity. If the remote host uses IPv6, it will then invoke 'ping6' command.
The multi-ping utility requires Net::DNS perl module. If you haven't install it yet, refer the following guide.
Now ping any domain using multi-ping tool as shown below.
$ ./multi-ping google.com Host google.com - 18.104.22.168 - alive Host google.com - 22.214.171.124 - alive Host google.com - 126.96.36.199 - alive Host google.com - 188.8.131.52 - alive Host google.com - 2001:4860:4802:34:0:0:0:75 - alive
- How To Ping Multiple Hosts At Once In Linux
- Ping Multiple Servers And Show The Output In Top-like Text UI
- Prettyping – Make The Output Of Ping Command Prettier And Easier To Read
It is simple Python HTTP server that allows you to instantly setup a basic file server.
$ ./pyhttpd 8080 Serving HTTP on 0.0.0.0 port 8080 ...
If you want to allow the server to be bound to localhost-only, rather than listening on all interfaces, run:
$ ./pyhttpd 127.0.0.1:8080 Serving HTTP on 127.0.0.1 port 8080 ...
As the name says, the randpass utility is used to generate a random password from command line.
$ ./randpass Gb39KTBu
To generate a password with specific length, use -n flag.
$ ./randpass -n 15 Xa7ZMA38tfOt7O2
It shows any new content since the last time a file was read. It is useful for tracking log files.
Remove the contents of apt history.log file:
$ ./since /var/log/apt/history.log >/dev/null
Now install or remove any applications. I remove Vim editor:
$ sudo apt remove vim
Now check the content of the history.log file:
$ ./since /var/log/apt/history.log Start-Date: 2020-01-28 11:52:59 Commandline: apt remove vim Requested-By: sk (1000) Remove: ubuntu-server:amd64 (1.417.3), vim:amd64 (2:8.0.1453-1ubuntu1.1) End-Date: 2020-01-28 11:53:05
The 'since' tool will only display the newly added contents in a file since the last time it was executed. If there are no contents added, it this script exits silently and you will not see any output.
It displays the expiry date of the SSL certificate of the given domain or host.
$ ./ssl-expiry-date google.com google.com Expires: Mar 31 15:47:12 2020 GMT Days: 63
You can also specify multiple domains with space-separated:
$ ./ssl-expiry-date google.com ostechnix.com google.com Expires: Mar 31 15:47:12 2020 GMT Days: 63 ostechnix.com Expires: Oct 9 12:00:00 2020 GMT Days: 254
To display only the number of days remaining on the certificate, use -d option:
$ ./ssl-expiry-date -d google.com ostechnix.com google.com: 63 ostechnix.com: 254
It allows the user to run a command for a specific interval and kill it.
$ ./timeout -t 10 top
As you can see, the above command kills the 'top' command after 10 seconds.
Kill a command after 10 minutes and 10 seconds:
$ ./timeout -t 10:10 top
Kill a command after 10 hours, 10 minutes and 10 seconds:
$ ./timeout -t 10:10:10 top
Please note that timeout utility is also available by default as part of GNU coreutils package. So probably won't need to the timeout program from sysadmin-uti package.
- How To Run A Command For A Specific Time In Linux
- How To Find The Execution Time Of A Command Or Process In Linux
- How To Run A Linux Command Every X Seconds Forever
- How To Add Linux Commands To The Queue And Execute Them One By One
There are few more tools available, such as Until-error & Until-success - repeat commands until it fails/succeeds, when-down & when-up - waits till a host is down/up, mysql-slave-check - find whether the current host is slave or not, which-shell - find the shell we're running under, etc.
Refer the project's GitHub page to learn more details of all tools.
Other useful tools for Linux sysadmins and noobs
Apart from Sysadmin-util, there are many other tools available that might be useful for Linux/Unix sysadmins as well as the newbies. We already have covered some of them.
1. Cockpit - Web-based system Monitoring tool
Cockpit is free, open source, server administration tool that allows you to easily monitor and administer Linux servers (single or multiple) via a web browser. It helps the system admins to do simple administration tasks, such as starting containers, administrating storage, configuring network, inspecting logs and so on. Check the following link to install and use Cockpit in Linux.
2. Netutils-linux - Network Troubleshooting And Performance Tuning Tools For Linux
Netutils-linux is a collection of useful utilities written in Python that can be used to simplify Linux network troubleshooting and performance tuning. To know more about these tools, refer the following guide.
3. Moreutils - more useful Unix utilities
If you're a Linux sysadmin, you will definitely heard about GNU core utilities. It comes pre-installed in all Linux distributions. But what about Moreutils? The moreutils is a collection of useful Unix utilities which are not included by default in the Unix-like operating systems. These utilities are often helpful for performing various operations on your Linux server easily and quickly. More details can be found in the below link.
4. Bash-Snippets - Useful BASH Scripts For Heavy Commandline Users
Bash-Snippets is a collection of useful BASH scripts for heavy commandline users who live in Terminal all day. Want to check the weather of a place where you live? There is a script to check it quickly. Wondering what is a specific stock price? There is a script for it too. Feel bored? You can watch some YouTube videos. All from commandline!! You don’t need to install any heavy, resource-intensive GUI applications. Click the following link to know how to use these scripts.
5. Debian-goodies - Command line tools for Debian and derivatives
Debian-goodies is yet another collection of useful utilities for DEB-based systems. Like moreutils, Debian-goodies also provides some additional useful commands which are not available by default. Using these tools, the sysadmins can do quite number of tasks, such as;
- which programs are consuming more disk space,
- which services need to be restarted after updating the system,
- search for a file matching a pattern in a package,
- list the installed packages based on the search string and a lot more.
Check the following link to get to know more about these goodies.
6. Some good alternatives to man pages
Man pages are great! There is no doubt about it. But, many man pages are comprehensive and lack in useful examples. You might have to go through the entire man page to find the detail of a certain option or flag. This is really time-consuming task when you wanted to learn a practical example of a specific Unix command using man pages. Not anymore! I know a few good alternatives to man pages which are focused on mostly examples, skipping all other comprehensive text parts. Read the below to link to learn about them.
7. Cli-fyi - A Command line tool to retrieve information about IP, Email, Domain and more
Cli.Fyi is a command line query tool to fetch information about IPs, Emails, Domains, Crypto currencies, media/url, UTC date/time, country and programming language etc. You can fetch all these details either from commandline or browser as described in the following link.
8. ExplainShell - A web-based tool that explains each argument of a Linux command
ExplainShell is a great resource for those who wanted to learn Linux command line arguments and options quickly and easily, without having to refer man pages. It breaks down the given command and explains what each part of a Linux command does. All you need to do is just copy and paste a Linux command in ExplainShell website, and it will instantly display what each part of a Linux command means.
9. Kmdr - Get CLI commands explanation in your Terminal
Kmdr is similar to ExplainShell but with some additional features. The ExplainShell helps you to learn Linux commands only. But what if you want to learn other CLI commands, for example Python? You won’t find explanation of Python commands in ExplainShell. This is where Kmdr comes in rescue. Kmdr provides explanation for a lot of CLI commands including ansible, conda, docker, git, go, kubectl, mongo, mysql, npm, ruby gems, vagrant and hundreds of other programs such as those built into bash. Sounds good? Great! Check the following link to learn to use Kmdr.
Like I already said, all of the aforementioned tools may not be useful all the time. Try one at a time and find if helps for your day-to-day job in any way.
These tools are not just for sysadmins, but for anyone who wants to improve their Linux command line skill-sets in general. I will keep adding more useful tools and applications in this list. If you feel any other tool should be added in this list, feel free to let me know in the comment section below. I will check and update the list accordingly.