Introduction
When working with Linux, we have many tools available for checking network status and troubleshooting network-related issues, such as whois, nslookup, and traceroute.
While studying the Linux Essentials course, I learned that we can easily create shell scripts, make them executable, and run them whenever needed. Shell scripts are widely used for automation, but they can also be useful for combining existing tools and customizing their behavior for specific needs.
I found that some common tools can be made more convenient or useful with a little customization. Below, I share some of these scripts and tools with you.
Table of Contents:
Before sharing Linux scripts and commands, I thought it would be useful to introduce aliases. When working with Linux, you may need to run the same long command many times a day, or you may encounter commands that are difficult to remember. In such cases, you can use an alias to run a long or less readable command using a short, memorable keyword. Aliases can save time, help you stay focused on your work, and reduce typing errors.
The best way to understand this is through real-world examples.
Connecting to an Old SSH Server
Sometimes you need to connect to a server running an old SSH configuration. For example, the server may still use the ssh-rsa host-key algorithm, and you may not be able to update its SSH package or configuration for some reason. In such a situation, you may need to use a command like this every time you connect: ssh -oHostKeyAlgorithms=+ssh-rsa -p 2022 root@example.com
Instead of typing the entire command every time, you can create an alias and use a short keyword such as srv1 and simply typing it in terminal instead. The alias expands to the full command in the background.
Running Shell Scripts from Anywhere
Aliases can also be useful for quickly running your own shell scripts. Normally, if your script is located in a specific directory, you need to provide its path when you are working from somewhere else. For example: /root/home/scripts/geo-trace.sh
This becomes inconvenient if you use the script frequently. You can create an alias for it and run the script from any directory using a short keyword such as geotr, and run the shell easily by typing the alias name instead. This is particularly useful when you have several custom scripts that you use regularly.
Creating an Alias
On Debian-based Linux systems using Bash, user-defined aliases are commonly stored in the .bashrc file. For a normal user, this is usually located in the user's home directory, such as: /home/username/.bashrc, and For the root user in /root/.bashrc.
Open the appropriate .bashrc file with a text editor such as nano: nano ~/.bashrc
Add your aliases, with each alias on a separate line:
alias srv1='ssh -oHostKeyAlgorithms=+ssh-rsa -p 2022 root@example.com'
alias geotr='/root/home/scripts/geo-trace.sh'
Save the file, then reload it with: source ~/.bashrc
The aliases are now available in your current terminal session. You can then run your commands or scripts from anywhere in the terminal:
$ srv1
$ geotr google.com
There is a package called whois that can be installed and used from the command line. For example, running whois 8.8.8.8 provides information about an IP address or domain. However, I found the output relatively lengthy and wanted a faster way to query my current public IP address and retrieve only the information I need.
To address this, I created Brief Whois, a lightweight Bash script that retrieves information about an IP address or domain directly from the command line. It provides details such as geolocation, ISP, timezone, and other relevant information in colorized JSON output.
The script can be used with or without an argument. When executed without an IP address or domain, it automatically detects and queries the public IP address currently being used to access the Internet. This provides a quick way to check your current public IP address, ISP, location, and related information.
For example: ./brief-whois.sh
To query a specific IP address or domain, provide it as an argument: ./brief-whois.sh 8.8.8.8
The script accepts both IP addresses and domain names, allowing you to quickly retrieve information for either type of target.
To read more about the script or install it, view the project on GitHub: View on GitHub
Screenshot of brief-whois shell script
When troubleshooting network connectivity, traceroute is commonly used to identify the hops between a source device and a destination. The way traceroute operates depends on the operating system. On Linux, the traditional traceroute command uses UDP probes by default, while Windows tracert uses ICMP Echo Requests.
One limitation of traceroute is that intermediate devices or firewalls may filter or drop the probe packets or the corresponding response messages. When this happens, traceroute may be unable to display the hop's IP address and round-trip time.
Another limitation is that standard traceroute output provides limited information about each hop. It does not normally identify the domain name assigned on hops, ISP name or geographic location associated with an IP address, requiring additional lookups to obtain this information.
To address these limitations, I created a customized tool called Geo-Trace. The tool traces network hops using both UDP and ICMP probes and displays their round-trip times. It also performs a Whois lookup for each discovered IP address and provides additional information such as the associated ISP and geographic location, and even domain names assigned on each IP address.
The project includes the script, example output, and installation instructions. To read more, view the project on GitHub: View on GitHub
Below you can see how a geo-trace query result will be shown to you:
...
11. UDP: 10.200.2.11 ICMP: 10.200.2.11
UDP: 203.694ms ICMP: 169.086ms
NA
Local Network
NA
12. UDP: NA ICMP: NA
UDP: NA ICMP: NA
Request timed out
NA
13. UDP: NA ICMP: 216.239.40.79
UDP: NA ICMP: 208.079ms
NA
Paris, Ile-de-France, France
Google LLC
14. UDP: 142.250.224.198 ICMP: 142.251.64.131
UDP: 202.020ms ICMP: 205.149ms
NA
Paris, Ile-de-France, France
Google LLC
15. UDP: 192.178.96.136 ICMP: 172.217.22.78
UDP: 195.799ms ICMP: 168.905ms
NA
Paris, Ile-de-France, France
Google LLC
16. UDP: 172.217.22.78 ICMP: NA
UDP: 200.855ms ICMP: NA
tlv04s05-in-f14.1e100.net
fra15s17-in-f78.1e100.net
tzpara-am-in-f14.1e100.net
fra15s17-in-f14.1e100.net
Paris, Ile-de-France, France
Google LLC
If you want to run a lightweight server while using the minimum amount of system resources, whether for a lab environment or a real project, you can use the minimal or core versions of Linux distributions. These versions typically do not include a graphical user interface (GUI) or unnecessary software packages. Instead, they provide the essential components needed to build and configure a server or service from the ground up.
Do not confuse these versions with NetInstall or Network Installation images. A NetInstall image contains only the files required to start the installation and downloads the remaining packages from the Internet during setup. Minimal or core distributions, on the other hand, generally include the required packages in the installation media and can be installed without an Internet connection.
The name and availability of these lightweight versions vary between distributions. For example, you may find CentOS Minimal or Ubuntu Server. However, not every Linux distribution provides a dedicated minimal or core edition.
Personally, I also use TurnKey Linux Core, a Debian-based distribution designed for lightweight server deployments. Compared with a typical Ubuntu Server installation, TurnKey Linux Core provides a relatively small base system while including useful management components such as Webmin and an SSH server for remote administration. I have used it to run various services for extended periods and have found it reliable for lab and server environments.
TurnKey Linux also provides specialized distributions for specific server applications, such as file servers, monitoring systems, WordPress, and many other services. These appliances come with the software required for their intended purpose already installed and configured, while remaining relatively lightweight.
If you are interested in lightweight Linux servers, especially the Core edition, I recommend visiting the official TurnKey Linux website to learn more about the available distributions and appliances.
For easier access, I have provided links to the resources mentioned below:
Ubuntu Server v26.04 LTS (3 GB)
CentOS v8.3.2011 Minimal (1.7 GB)
TurnKey Linux Core v18.1 (392 MB)