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.

About Sysadmin-util

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:

ago chronic cidr2ip collapse dupes empty-dir expand-ipv6 flush-firewall graphite_send ipaddr maybe mk-passwd-hash multi-ping mysql-slave-check pyhttpd randpass since splay ssh-auth-types ssh-test ssl-expiry-date timeout until-error until-success when-down when-up which-shell with-lock

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

Ago

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>

Examples:

$ ./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.

Related read:

Chronic

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.

Example:

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

Cidr2ip

It converts CIDR blocks into their constituent IP addresses.

Example:

$ ./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 [...]

Collapse

The collapse tool removes blank lines and lines that contains white-space from the given file(s).

Example:

$ echo -e "Linux is not an OS.

It is a Kernel.



Gnu/Linux is the OS.







" | ./collapse Linux is not an OS. It is a Kernel. Gnu/Linux is the OS.

Dupes

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.

Example:

$ ./dupes ./.git/logs/HEAD ./.git/logs/refs/remotes/origin/HEAD ./.git/logs/refs/heads/master

Related read:

Empty-dir

This tool will test whether the given directory is empty or not.

Example:

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.

Expand-ipv6

This tool expands the given abbreviated/compressed IPv6 addresses to their full-form. It can be useful when setting up DNS entries.

Example:

$ ./expand-ipv6 fe80::a00:27ff:feff:d2e0 fe80:0000:0000:0a00:27ff:feff:d2e0

Multi-ping

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.

Example:

$ ./multi-ping google.com Host google.com - 216.239.36.117 - alive Host google.com - 216.239.32.117 - alive Host google.com - 216.239.38.117 - alive Host google.com - 216.239.34.117 - alive Host google.com - 2001:4860:4802:34:0:0:0:75 - alive

Related read:

Pyhttpd

It is simple Python HTTP server that allows you to instantly setup a basic file server.

Examples:

$ ./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 ...

Related read:

Randpass

As the name says, the randpass utility is used to generate a random password from command line.

Examples:

$ ./randpass Gb39KTBu

To generate a password with specific length, use -n flag.

$ ./randpass -n 15 Xa7ZMA38tfOt7O2

Related read:

Since

It shows any new content since the last time a file was read. It is useful for tracking log files.

Example:

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.

Ssl-expiry-date

It displays the expiry date of the SSL certificate of the given domain or host.

Examples:

$ ./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

Timeout

It allows the user to run a command for a specific interval and kill it.

Example:

$ ./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.

Related read:

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