Skip to main content
Troubleshooting

Ping Command Not Found? Install Ping on Ubuntu

If you are running Ubuntu in a Docker container, ping command will be missing. You can install ping on Ubuntu with this simple trick.

Abhishek Prakash

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.

root@139a76a6e5d4:/# 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.

root@139a76a6e5d4:/# apt install ping
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ping
Ping command not found in Ubuntu when running in Docker

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):

apt update

Now, install the iputils-ping package with this command:

apt install iputils-ping
Installing ping command on Ubuntu

Now, you can use the ping command.

root@139a76a6e5d4:/# ping itsfoss.com
PING itsfoss.com (104.26.10.68) 56(84) bytes of data.
64 bytes from 104.26.10.68 (104.26.10.68): icmp_seq=1 ttl=56 time=25.1 ms
64 bytes from 104.26.10.68 (104.26.10.68): icmp_seq=2 ttl=56 time=49.6 ms
64 bytes from 104.26.10.68 (104.26.10.68): icmp_seq=3 ttl=56 time=34.8 ms
64 bytes from 104.26.10.68 (104.26.10.68): 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
ping command running in Ubuntu

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.

Abhishek Prakash