blog posts

How to Use the Linux Ping Command

PING or Packet Internet Groper is one of the most popular Linux commands whose main purpose is to manage the network connection status between the source and the device with the help of an IP network. In this tutorial, you will learn how to use the ping command.

What is the Linux ping command?

With the ping command in Linux, we can access a network’s duration of sending and receiving responses. It works by sending a series of ICMP protocol messages to the target host and waiting for an ICMP echo message from the host and the device, which informs us that the network is online.

It sends an ECHO_REQUEST message and waits for an ECHO_RESPONSE. If it shows the message “fast ping, low latency,” the connection is fast. The speed of this connection is measured in milliseconds.

Every computer, VPS, or modern device has PING installed by default due to its many applications. The ping command is a quick and simple way to check performance between a device and a host.

Ping provides us with detailed connection details of all types of networks. From local area network (LAN) to wide area network (WAN). It also receives a statistical summary, including the minimum and maximum rounds, the number of packets sent and received, the percentage of lost packets, and the average standard deviation. In addition, it allows the user to check the quality of the network connection between two devices.

You can determine the following by using the ping command between your computer and the target server:

  • Status of the target host: reachable or not.
  • Measurement of round trip time (host – computer – host)
  • The percentage of lost packages

How to install the Linux ping command

 

Remember; first, we need to access our VPS using SSH. If you need more guidance on this, visit this link. (connecting to the server with PuTTY software)

Ping should be installed by default in most Linux versions. To check this, enter the following command in Terminal:

ping -V

If ping is not installed, simply do it with the following command:

apt-get update && apt-get install -y iputils-ping

How to use the Linux ping command?

 

There are several options in Linux that allow the user to test the connection between two networks. In the following, we will examine some of them.

1. Checking Connectivity

You can check the status of the host and the desired server or computer by running this simple and quick command in your system.

In this example, we check the network connection with Ded9.com:

ping Ded9.com

Note: If you are not sure about the domain of the host, you can use the host’s IP address or VPS.

  • min – refers to the minimum time to receive a response.
  • avg – shows the average response time.
  • min – indicates the maximum time to receive a response.

To stop the ping command in Linux, we need to use Ctrl+C to stop sending packets to the target host. You can use Ctrl+C to stop all terminal processes.

2. Determine the ECHO_REQUEST number

The c-command is used to specify the number of requests that the user wants to make.

The syntax is as follows:

ping –c * exampledomain.com

Here * is the number of pings you want to do.

3. Audible Ping

The Linux ping -a command creates a beep to check if the host is active and notifies you audibly.

The command will be as follows:

ping –an exampledomain.com

Remember, press Ctrl+C to end the ping process.

4. Determining distances

The –i option in Linux allows the user to set the time interval in seconds between each request.

An example of this command:

ping –i 2 –c 7 exampledomain.com

Here you can change the numbers as needed.

5. Get a summary of the network status with the ping command

If you just want to get a summary of the network, use the –q option on the Linux terminal command line:

ping –c 7 –q exampledomain.com

In this example again, we still use -c 7 to do seven requests, but we only get the summary because of the addition of -q.

6. Filling the network with the Linux ping command

The ping command allows users to send 100 or even more commands per second using the following command:

ping –f exampledomain.com

This command is a great option if you want to test how your website or server handles a large number of requests.

Conclusion

Ping is a common tool for troubleshooting access to hosts on a network. The ping command helps us find out why a website is not loading. Ping is a command that helps us determine the reachability of a network device.

Since it is fast and simple, many users prefer to use it for troubleshooting.