Usually, the ping command is already installed on most Linux systems.
But in some rare cases like when you have Ubuntu minimal install or you are running Ubuntu in a Docker container, the ping command is missing. If you try to use it, you will see the ping not found error.
[email protected]:/# ping itsfoss.com bash: ping: command not found
That's not the worst thing. You try to install ping and then it complains that it is unable to locate package ping.
[email protected]:/# apt install ping Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package ping
Now it gets confusing. Can you not use ping in Ubuntu? Is there no ping command in Ubuntu? That cannot be right, isn't it?
Installing ping on Ubuntu
The problem here is that ping command is not a package itself. It is part of iputils package. This is when you try to install a package named ping, it cannot be found.
The actual ping package as part of iputils is called iputils-ping. This is the package you have to install for ping.
First, update the local package cache by running this command as root (use sudo if you are not root):
Now, install the iputils-ping package with this command:
apt install iputils-ping
Now, you can use the ping command.
[email protected]:/# ping itsfoss.com PING itsfoss.com (126.96.36.199) 56(84) bytes of data. 64 bytes from 188.8.131.52 (184.108.40.206): icmp_seq=1 ttl=56 time=25.1 ms 64 bytes from 220.127.116.11 (18.104.22.168): icmp_seq=2 ttl=56 time=49.6 ms 64 bytes from 22.214.171.124 (126.96.36.199): icmp_seq=3 ttl=56 time=34.8 ms 64 bytes from 188.8.131.52 (184.108.40.206): icmp_seq=4 ttl=56 time=38.9 ms ^C --- itsfoss.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms rtt min/avg/max/mdev = 25.125/37.095/49.590/8.773 ms
If you are using this in a Docker container, you know that changes you made in the container are temporary. You should use Dockerfile to make permanent changes to the image and the subsequent containers.
I hope you find this quick tip helpful in installing ping command on Ubuntu. If you still have questions or suggestions, please let me know in the comment section.