×


Different ways to use Ping command on Linux Mint 20 ?

The ping command in Linux is used to serve multiple purposes. These uses include checking if a host is reachable, verifying if a server is up and running, checking your Internet connection, and also to check any potential delays in the network. 

Apart from the basic usage of the ping command in Linux, there are several flags and options with which the Ping command can be used to serve multiple purposes.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Ubuntu related tasks.

In this context, we shall look into how to use the Ping command in Linux Mint 20. 


Different ways to use the PING Command in Linux Mint 20 ?

Before getting started with the examples of the ping command in Linux Mint 20, we would like to walk you through its help manual in the following manner:

ping --help

Running this command will not only display the syntax of the ping command but will also enlist all the different options and flags with which this command can be used. 

You can scroll down this list to see all the flags and options.


Now by using the help manual of the ping command, we have created a few examples of its usage as follows:


Example # 1: Simply Trying to Reach a Host:

The simplest use of the ping command is to try to reach a host by specifying its URL after the Ping command as shown below:

ping google.com

Here, you can replace google.com with any other host of your choice.

When this command will be executed, the Ping requests will be sent after every second to the specified host.


At any point in time, if you feel like stopping this process, you can do it by pressing "Ctrl+ C". When the Ping process will terminal, you will be able to see its summary which will include things like the number of packets sent, round trip time (RTT), and so on.


Example # 2: Producing a Sound while Pinging a Host:

You can also cause a sound to be produced whenever you ping the desired host. This can be done in the manner shown below:

ping –a google.com

Here, the "-a" flag is used to produce an audio/ beep/ sound along with each ping output whereas visually, that output will appear to be the same as Example # 1.


Example # 3: Checking the Local Network:

You can also check your local network with the help of the ping command in the following manner:

ping localhost

By running this command, you will be able to find out the IP address of your localhost.


Example # 4: Setting a Specific Time Interval between Ping Packets:

As we have mentioned in Example # 1, the default time interval between two ping packets is 1 second. 

However, we can always change this time interval as per our requirements by running the Ping command in the following manner:

ping –i 2 google.com

Here, you can replace "2" with any time (in seconds) of your choice that you want to keep between two ping packets. In our case, a ping packet will be sent 2 seconds after the previous one.


Example # 5: Flooding a Host with Ping Requests:

You can also flood the desired host with ping requests in the following manner:

sudo ping –f google.com

For flooding a host with ping requests, you will require root user privileges. However, as soon as you want this process to terminate, you can do this by pressing "Ctrl+ C".


Example # 6: Changing the Size of the Ping Packet:

The default size of a ping packet is 56 bytes. 

You can choose to increase or decrease this size according to your requirements in the following manner:

ping –s 100 google.com

Here, you can replace "100" with any size (in bytes) of your choice that you want for your ping packet. Our newly sent ping packets will now have the size of 100 bytes after running this command and this can be verified from the size.

Also, the number that is written between parentheses depicts the total size which also includes the 28 bytes of the header.


Example # 7: Limiting the Number of Ping Packets:

As you can see from the examples above that the Ping command starts sending infinite packets to the specified host and you need to forcefully stop this process. However, you can also limit the number of ping packets that you want to send by running the command stated below:

ping –c 3 google.com

Here, you can replace "3" with whatever number of ping packets you wish to send. After sending the specified number of the ping packets, this command will terminate automatically.

From the output of this command, you can easily verify that only three ping packets were sent in this case.


Example # 8: Setting a Time till you want to send the Ping Packets:

Instead of limiting the number of ping packets, you can also specify a time interval till which you wish to keep sending the ping packets in the manner shown below:

ping –w 10 google.com

Here, you can replace "10" with the time interval (time in seconds) till which you wish to keep sending the ping packets to the specified host. Once that time will expire, this process will terminate automatically.


Example # 9: Getting only the Ping Statistics:

Instead of seeing the output of every single ping packet, you can also choose to view the summary of the whole process by running the Ping command in the manner shown below:

ping –c 5 –q google.com

Here, we have intentionally used the "-c" flag so that we can specify the number of ping packets whose summary we want to get. The "-q" flag will serve the purpose of displaying the summary.


Example # 10: Displaying the IP Addresses in the Ping Output:

If you wish to display the IP address of the location from where the ping packets were sent instead of the hostnames, you can use the Ping command in the manner shown below:

ping –n google.com


Example # 11: Displaying the Timestamps with the Ping Output:

If you also want to know the exact time according to your system's clock at which a particular ping packet was sent, then you need to run the command stated below:

ping –D google.com

The timestamps of each packet are shown before the other details related to every packet.


Example # 12: Asking for a Specific Internet Protocol with Ping:

With the Ping command, you can also specify the Internet protocol for receiving either IPv4 or IPv6 addresses in the manner shown below:

ping -4 google.com

Here, you can replace "-4" with "-6" if you wish to see the IPv6 addresses.


[Need to urgently install packages on Linux Server? We are available to help you today. ]


Conclusion

This article will guide you on different ways to demonstrate the usage of the #ping #command in Linux Mint 20. You can also combine two or more flags to serve a different purpose of your choice.

The #Linux ping command is a simple utility used to check whether a network is available and if a host is reachable. With this command, you can test if a server is up and running. It also helps with troubleshooting various connectivity issues.

To use ping command:

1. Open a Command Prompt. Click on the Start Menu and in the search bar, type 'cmd', and press Enter.

2. In the Command Prompt window, type 'ping' followed by the destination, either an IP Address or a Domain Name, and press Enter.

3. The command will begin printing the results of the ping into the Command Prompt.