Select Page

Introduction

You probably already know that the traceroute command in Linux allows you to troubleshoot the route through which a network packet has to travel. It is available in many UNIX distributions like MacOS and Linux. However, a few recent versions of Linux don’t seem to have the package in their repositories, in which case, you’ll need to find alternatives for the traceroute command.

The traceroute command is pretty useful when you need to diagnose broken routes that may prevent the packets from reaching other DNS servers. Unfortunately, people seem to have problems running the traceroute command itself! So how do you expect to fix a broken path if the road roller itself is not working! If your system has the traceroute package in its repositories, getting it to run could be as easy as pie. However, if your system does not have it, you’ll probably have to take the longer route, which is to compile it from source.


-bourne again shell: traceroute: command not found

You’re in Linux, probably using the default bourne again shell. You typed a traceroute command to measure network stats, and you got this error:

-bourne again shell: traceroute: command not found

Or perhaps you’re a pro user and decided to use zsh instead of bourne again shell. In which case you got this error when you tried a traceroute command:

zsh: command not found: traceroute

The best way to fix this error is to install the traceroute command. There’s a couple ways to do this: first is with a package manager for your distro, or you could try compiling traceroute from source.


Install the traceroute command in Linux

Before you can use the traceroute command in Linux, you need to have it installed in your system first! it does not come shipped by default in Linux distributions now, and a lot of distributions don’t even have it in their repositories, as mentioned before. But luckily, the traceroute command is getting some love once again after quite some time! Some of the distributions like Ubuntu and Arch Linux still seem to favor the traceroute command over alternatives.

The command to install traceroute will differ based on the linux distribution you are using. Some of the distributions are listed below:

Arch Linux: 

$ sudo pacman -Syu traceroute

Ubuntu/Debian:

$ sudo apt-get update 
$ sudo apt-get install traceroute

Fedora:

$ sudo yum makecache 
$ sudo yum install traceroute

Redhat/CentOS:

$ sudo yum makecache 
$ sudo yum install traceroute

The above commands should fix the traceroute: command not found error for most users. however, there are a few cases where you may be unable to install. There are two ways you can get around that. Firstly, you’ll need to install the traceroute command from the source code, or else, if you don’t want to get into that mess, you may wish to use some alternative tools to the traceroute command that’ll give you similar functionalities. We’ll be discussing elaborately in the upcoming sections.


Compile traceroute command from source

For distributions that don’t have the traceroute package in their repositories, it is possible to install the command from source, which is found under subdirectories in the GitHub page of OpenBSD. However, downloading it and then installing it can be quite tedious and time consuming as you won’t be able to download only the subdirectory.

Instead, you can download the source files from another website, which states to be a modern implementation of the old traceroute command. 

https://traceroute.sourceforge.net/

Visit the website and download the traceroute source code from SourceForge. There are several versions of it, the latest of which being 2.1.0, which by itself, seems to be a bit old too. You can also directly download it by click on the link below, if you wish to:

https://sourceforge.net/projects/traceroute/files/latest/download

Once the download is over, navigate to the download directory and then extract the archived file by using:

tar -xzf traceroute-2.1.0.tar.gz

Then, Enter the extracted directory:

cd traceroute-2.1.0/

Now run make to compile the package:

make

Lastly, install the package system-wide:

sudo make install

Wala! You should now be able to run the traceroute command in your Linux Machine. Try it out by running it for once:

traceroute www.google.com

As a side note, it is also possible that the PATH variable of your system is not set properly, for the bourne again shell shell to scan. If the directory where traceroute is installed is not scanned by bourne again shell, then you’ll not be able to execute the command. To fix this, you need to add one line to your .bashrc file, which should be located in your home directory (if you don’t know what it is, .bashrc is just a configuration file for bourne again shell).

Add the following line to your .bashrc file, just in case:

export PATH=/usr/bin:$PATH

Alternatives for traceroute command

The traceroute command has gotten quite old, and is out of support. Which is why, there are a few alternatives to traceroute command, if all the above had failed for you, or you simply want to try out something else. 

There are two common alternative commands to traceroute – the tracepath command and mtr command. Mtr is highly favoured by its users, and is taken as a great alternative to traceroute. Plus, the user interface of Mtr is easier to look at and is more organized, if you were to ask me. It also has a dedicated Display Mode option which shows you the paths in different ways, both with informative text as well as a nice-to-look-at visualization of the data that is represented in dots and question marks. The mtr command is found in most linux distributions, installing which can be as easy as replacing traceroute with mtr in the How to Install section. 

Besides mtr, the tracepath command is not bad either if you don’t want that many features. It is simple, and does only one job – give you just the route information with their respective times in milliseconds. For the tracepath command, you won’t find any package for it if you try installing it by using your package manager, simply because you don’t need to do that anyway. It comes shipped by default. You can simply run in by using the tracepath command followed by the IP Address or the name of the DNS Server. Aha!


Conclusion

I am pretty hopeful that you have successfully been able to surpass the traceroute: command not found issue after this. The command does not come shipped into systems for the most part, so simply installing it should do the job for you. If you wish to use traceroute diagnostics in a Mackintosh Machine, you should be able to do it with the help of the Network Utility GUI tool which should be a lot nicer. On the other hand, if you’re using Linux but your system does not have the traceroute package, building it from source is the only option, if you don’t prefer the alternatives.