You may receive the below error on a Linux server which is caused by traceroute not being installed. The chances are that if traceroute is not installed that the tracepath package is installed. The difference between the two is that tracepath does not require superuser privileges and traceroute does require super user privileges. Below is information on the traceroute error, how to install traceroute using yum on CentOS Linux, or how to alternatively use tracepath instead of traceroute.
Error: -bash: traceroute: command not found
Example Attempt To Use Traceroute When Traceroute Is Not Installed:
- [root@server ~]# traceroute google.com
- -bash: traceroute: command not found
The above error simply means that traceroute is not installed. To resolve this issue you just need to install the traceroute package which can easily be completed using any package manager. The below example shows traceroute being installed using the yum package manager on CentOS Linux.
Install traceroute Using Yum On CentOS Linux:
- [root@server ~]# yum install traceroute
- Loading "installonlyn" plugin
- Setting up Install Process
- Setting up repositories
- pgdg83 100% |=========================| 1.9 kB 00:00
- rpmforge 100% |=========================| 1.1 kB 00:00
- base 100% |=========================| 2.1 kB 00:00
- updates 100% |=========================| 1.9 kB 00:00
- addons 100% |=========================| 951 B 00:00
- ruby 100% |=========================| 951 B 00:00
- extras 100% |=========================| 1.1 kB 00:00
- Reading repository metadata in from local files
- primary.xml.gz 100% |=========================| 3.5 MB 00:02
- ################################################## 9581/9581
- Parsing package install arguments
- Resolving Dependencies
- --> Populating transaction set with selected packages. Please wait.
- ---> Downloading header for traceroute to pack into transaction set.
- traceroute-2.0.1-5.el5.x8 100% |=========================| 9.3 kB 00:00
- ---> Package traceroute.x86_64 3:2.0.1-5.el5 set to be updated
- --> Running transaction check
- Dependencies Resolved
- =============================================================================
- Package Arch Version Repository Size
- =============================================================================
- Installing:
- traceroute x86_64 3:2.0.1-5.el5 base 41 k
- Transaction Summary
- =============================================================================
- Install 1 Package(s)
- Update 0 Package(s)
- Remove 0 Package(s)
- Total download size: 41 k
- Is this ok [y/N]: y
- Downloading Packages:
- (1/1): traceroute-2.0.1-5 100% |=========================| 41 kB 00:00
- Running Transaction Test
- Finished Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing: traceroute ######################### [1/1]
- Installed: traceroute.x86_64 3:2.0.1-5.el5
- Complete!
- [root@server ~]#
So now that traceroute is installed you can use the traceroute command with no issues as long as you are a super user. So below is an example using traceroute from your location to google.com.
Use Traceroute From Server To Google:
- [root@server ~]# traceroute google.com
- traceroute to google.com (209.85.225.104), 30 hops max, 40 byte packets
- 1 67-207-123-25.slicehost.net (67.207.123.25) 0.145 ms 0.133 ms 0.118 ms
- 2 209-20-79-2.slicehost.net (209.20.79.2) 0.554 ms 0.544 ms 0.604 ms
- 3 ge-6-13-163.car1.StLouis1.Level3.net (4.53.160.241) 51.406 ms 48.345 ms 42.521 ms
- 4 ae-11-11.car2.StLouis1.Level3.net (4.69.132.186) 0.505 ms 0.599 ms 0.623 ms
- 5 ae-4-4.ebr2.Chicago1.Level3.net (4.69.132.190) 5.876 ms 5.862 ms 5.917 ms
- 6 ae-21-56.car1.Chicago1.Level3.net (4.68.101.162) 6.390 ms ae-21-52.car1.Chicago1.Level3.net (4.68.101.34) 6.065 ms ae-21-54.car1.Chicago1.Level3.net (4.68.101.98) 6.353 ms
- 7 GOOGLE-INC.car1.Chicago1.Level3.net (4.79.208.18) 20.466 ms 20.445 ms 20.447 ms
- 8 209.85.254.122 (209.85.254.122) 17.018 ms 17.062 ms 209.85.254.130 (209.85.254.130) 16.928 ms
- 9 209.85.241.22 (209.85.241.22) 19.307 ms 72.14.232.141 (72.14.232.141) 18.049 ms 209.85.241.22 (209.85.241.22) 18.321 ms
- 10 209.85.241.29 (209.85.241.29) 18.166 ms 18.069 ms 17.974 ms
- 11 209.85.248.102 (209.85.248.102) 18.779 ms 66.249.95.138 (66.249.95.138) 18.263 ms 72.14.239.18 (72.14.239.18) 21.002 ms
- 12 iy-in-f104.1e100.net (209.85.225.104) 18.608 ms 18.295 ms 18.296 ms
- [root@server ~]#
So if you need to provide traceroute to users who do not have super user privileges you could instead use tracepath. Below is an example using tracepath with no switches to google.com.
Use Tracepath As A Traceroute Alternative On Linux:
- [root@server ~]# tracepath google.com
- 1: example.com (67.207.123.26) 0.115ms pmtu 1500
- 1: 67-207-123-25.slicehost.net (67.207.123.25) 0.261ms
- 2: 209-20-79-2.slicehost.net (209.20.79.2) 0.642ms
- 3: ge-6-10-193.car1.StLouis1.Level3.net (4.53.160.189) 0.965ms
- 4: ae-11-11.car2.StLouis1.Level3.net (4.69.132.186) 0.797ms
- 5: ae-4-4.ebr2.Chicago1.Level3.net (4.69.132.190) 17.356ms
- 6: ae-21-54.car1.Chicago1.Level3.net (4.68.101.98) 6.656ms
- 7: GOOGLE-INC.car1.Chicago1.Level3.net (4.79.208.18) asymm 12 18.477ms
- 8: 209.85.254.122 (209.85.254.122) asymm 11 18.010ms
- 9: 72.14.232.141 (72.14.232.141) asymm 11 18.428ms
- 10: 209.85.241.29 (209.85.241.29) asymm 13 18.317ms
- 11: 209.85.248.102 (209.85.248.102) asymm 13 21.223ms
- 12: iy-in-f99.1e100.net (209.85.225.99) asymm 14 18.492ms reached
- Resume: pmtu 1500 hops 12 back 14
- [root@server ~]#
Now regardless of privileges you should be able to trace to any server necessary. If you did need traceroute specifically you can easily install using yum on CentOS or any other package manager on another Linux distribution. Traceroute or tracepath will each show you the millisecond (ms) delay from your server to each hop (device) between you and your destination. So in the case of the above examples you can see that there are 12 hops between this server and google.com.