Ubuntu

Ping Command not found on Ubuntu Linux

Does your system face an issue finding the ping command? Don’t worry; we have your issue resolved!

In the modern era of computers, we are connected across multiple devices via various networks. These networks help establish connections across our devices like handhelds, desktop computers, watches, and many more. We can effortlessly send considerable chunks of data from one point to another across the globe using these services.

This has all become possible due to computer communication using various networks. However, sometimes our computer may not be able to reach the desired network, resulting in a discontinuity in connection from a network. This is where the ping command comes in.

Ping command

Ping is defined as a tone with a high pitch and a sharp resonance. Computer and network monitoring used it as a test to determine the time to reach a particular target. This target may be another computer or a network destination like a server, router, etc.

The message is bounced back by the recipient with a reply to the ICMP echo request sent by our device. You can think of it as a submarine system. A submarine sends a sonar to detect an object, and the object reflects the echo, which tells the submarine the relative distance of the object.

Similarly, the ping command sends a packet (echo request) to the destination. How much time is consumed until a response is received, and the ping command determines the number of returned responses? The command determines the activity of the remote host, i.e., is it active, along with the time taken and packet loss.

Time taken is the delay in one cycle from host to system (usually in milliseconds). The time delay should not exceed a specific limit referred to as a “timeout”. If a remote host takes more than the specified time of server/router/computer, we get a “timeout” error implying the echo-response or “ping” did not reach in sufficient time specified for the reception. This is referred to as TTL or “time to live”.

To test the level of consistency in connection, there are several initiations of pings, i.e., 4 to 5 echo requests may be sent by the ping command to test the success of connection, and results are displayed like the number of bytes received, TTL, and rate of packet loss.

Now that we have a good idea of what ping does and how it does it, let’s dive into the process of its installation on Ubuntu Linux.

By default, the ping command is a part of the Ubuntu package called “iputils” which is a collection of several useful utilities to monitor our network performance. They come installed in most systems, but if they are not found, we use the following set of commands to install the package.

$ sudo apt update
$ sudo apt install iputils-ping

This enables the utility of the ping command in a docker for our Linux system.

Test ping command

You can test your connectivity to a remote host via the ping command by typing.

$ ping localhost

This will enable the system to send “pings” to test the connectivity of your system and to determine whether the remote host is active. You may also use your IP address to determine its packet loss rate by typing.

$ ping [your ip-address]

We can check our IP address on Linux using.

$ ipconfig

Press ‘Ctrl+C’ to abort the operation. Consequently, the command will show you the overall results, including the number of packets transmitted and received in a cycle and the time taken to retrieve them.

Here, you’ll see several test packets “pinged” to the remote host for a response. The icmp-seq is the serial number of requests sent by your localhost, the system. “Ttl” is the number of nodes of a network taken by a packet. This term is constant and cannot be changed. Time is the duration for the packet to complete the transmission cycle from local to remote host and back.

Limit pings

You can limit the number of packets sent by using the following command.

$ ping -c 6 google.com

Flood a network

You can see a network performance under load by flooding it via ping command. This can be done by typing.

$ ping -f google.com

Ping to a certain server

You may also ping any server of your choice by typing in its URL.

The aforementioned command will show the network connectivity to and from the said network.

Troubleshooting

Ping command can be used in various ways to test the network on our device and the response from other networks.

We may send a ping to an IP address to determine if it responds. If it fails, this means the device is inactive at the moment, or the network traffic is such that we can’t reach the device. If the response time is greater, that means there are probably connectivity issues at either or both sides, depending on the time taken.

In case we can’t reach a hostname, but the IP address seems accessible, this can mean there is a problem with hostname resolution. This means the DNS server may not be accessible.

We can check and balance our network activity by keeping ping as a “run till stopped” option, which enables the continuous function of the ping command unless something fails. We can also test various parts of the network to determine their functionality at any moment.

Several options for ping

The ping command has various options for effective network monitoring. We can access these options by typing.

$ ping -help

Or

$ ping -?

This will open a variety of options, showing their symbols along with a brief explanation.

Uninstall the ping command

We can uninstall the ping command by uninstalling the iputils package.

$ sudo apt-get remove iputils-ping

To uninstall all dependencies.

$ sudo apt-get remove –auto-remove iputils-ping

Purge all data and configuration.

$ sudo apt-get purge iputils-ping

Conclusion

This article covered the ping command, a command used to test our network speed and its reception to other networks. It may be used for troubleshooting networks or connectivity across various devices. It works on most systems as it is a universal command. We looked into its installation and working, such as various options and troubleshooting.

We hope you were able to install ping successfully and were able to make the best use of this command after reading this article.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.