How to Use Ping Command on Ubuntu 22.04

How to Use Ping Command on Ubuntu 22.04

Understanding how to use ping command on Ubuntu 22.04 can help you identify the connectivity details and any issues that may exist. Read on to find out more!

The ping command is a utility for Windows, Linux, and other operating systems. It can be used for connectivity among two hosts in the network. It records various metrics, such as the time to transfer a packet from one host to another. In addition, this command can resolve the hostname to the IP address. In this guide, we will explain the usage of the ping command in Ubuntu 22.04.

Ping Command

The ping command uses Internet Control Message Protocol (ICMP)’s echo requests to remote hosts and waits for the response. The ICMP protocol works at the network layer of the open system interconnection (OSI) protocol. The remote system, if reached, can send the response back, i.e., echo reply. 

This will imply that the remote system is reachable along with the time to send an echo message to the host. This command can identify network connectivity issues and round trip to transmit the message from sender to host and then host back to the sender. A longer response time may imply that the network is congested or the packets are dropped in transit.

How to Use Ping Command on Ubuntu 22.04

Now that we’ve taken a closer look at the ping command and its importance, it’s time to move forward. Before you can begin using the ping command on Ubuntu, you will need to install it, and here’s how you can do it.


To install the ping command, first, upgrade the system via the following command:

$ sudo apt update && sudo apt upgrade

Now, type the following command in the terminal to install ping in your Ubuntu machine:

$ sudo apt install iputils-ping

To verify the installation, type the following command:

$ which ping

If you want to remove the ping command from your system, you can type the following on the terminal:

$ sudo apt remove iputils-ping

Usage of the command

The general usage of the ping command is as follows:

$ ping options host-name/IP

Here, the hostname is the name of the host to which the ping message is sent. For instance, to check that is reachable, you can write the following command on the terminal. Open the terminal and type:


The output is continuously updated, and the ping command sends echo requests periodically to the host. You can stop the ping command by pressing Ctrl + C. Once the command is stopped, it displays the statistics for the host. 

This information includes the host’s internet protocol (IP) address, time to live value (TTL), and the response time in milliseconds. It also shows the summary of the number of packets sent, the percentage of packet loss, the number of times the command is run, and the max, min, and average response time.

Ping Options

Now, we will look at the various options for the ping command.

Change packet size

You can change the size of the ICMP packet sent to a remote host. The default packet size is 56 bytes plus the packet header size of 28 bytes, making it a total of 84 bytes. However, you can change the packet size with the –option in the ping command:

$ping -s packetsize <host>

This can be used to test the network performance with varying packet sizes.

Specifying the number of ping requests

One can specify the number of ping requests sent to the host using the –c option. For instance, the following command can be used to determine that 10 ping requests are to be sent to the host:

$ ping -c 10

Specifying the packet interval

The interval between sending ICMP packets to the host, which is 1 sec, can be changed with the –i option. For instance, the following command sends the packets with an interval of 5 seconds:

$ ping -i 5

Flooding a network

To see how my network responds to a denial of service (DoS) attack, you can flood the network with the –f option. To execute the flood command, you must log in as a superuser.

$ sudo ping -f

The output of this command will show the number of packets sent and received. Note that this command should be run for a few seconds as this will congest your network with many ICMP requests.

Other options

Several other options for the ping command, such as –w, can be used for specifying the hard timeout. The following command shows an example:

$ ping -w 5192.168.0.2

The above command will stop after 5 seconds. There is an option –w for specifying a soft timeout. Also, you can listen for a beep with a ping command. You can make the ping quiet and only display the summary using the –q option. You can use the –v option to find the versions of the ping command.

This article has looked at the ping command in detail with various options. Using the ping command, we can test the connectivity among the hosts and troubleshoot the connectivity issues.

If this guide helped you, please share it.

Leave a Reply
Related Posts