Most Useful Linux Ping Command (Ping Utility) With Examples

In this article, we are going to learn how to use the Linux ping command also known as ping utility. PING stands for Packet Internet Network Groper is a network-related tool used to check network connectivity between two systems with the help of IP Address or Hostname, for example between two servers or two clients or between any two devices which are in-network. To do so ping uses ICMP (Internet Control Message Protocol) to transfer and receive the packets between two devices. In simple words, the ping command is used as a Networking Troubleshooter. ping command was invented by Sir Mike Muuss in the year 1983.

Most Useful Linux Ping Command (Ping Utility) With Examples

Most Useful Linux Ping Command (Ping Utility) With Examples

Follow the below article for Linux ping command (ping Utility) with Examples :

Syntax to use Linux ping command is :

ping [OPTIONS] [Hostname/IP Address]

To check network connectivity between any system or networking device (Router, Server, etc.) we can use the ping command. Here I checking the connectivity of one of my desktop systems whose IP Address is 192.168.1.103 and as shown in the output below I have positive connectivity.

[root@localhost ~]# ping 192.168.0.103  # To check connectivity of any system/networking device 
PING 192.168.0.103 (192.168.0.103) 56(84) bytes of data.
64 bytes from 192.168.0.103: icmp_seq=1 ttl=64 time=0.100 ms
64 bytes from 192.168.0.103: icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from 192.168.0.103: icmp_seq=3 ttl=64 time=0.057 ms
64 bytes from 192.168.0.103: icmp_seq=4 ttl=64 time=0.049 ms
64 bytes from 192.168.0.103: icmp_seq=5 ttl=64 time=0.051 ms

--- 192.168.0.103 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4030ms
rtt min/avg/max/mdev = 0.049/0.064/0.100/0.020 ms

To ping to Localhost or Your own system refer the below ping command.

[root@localhost ~]# ping localhost  # To ping your Own System
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.043 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.041 ms

--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3880ms
rtt min/avg/max/mdev = 0.034/0.039/0.043/0.003 ms

You can check connectivity with any domain name or website by using the ping command (ping utility). Here I am checking connectivity with my own website i.e. itsmarttricks.com.

[root@localhost ~]# ping itsmarttricks.com   # Check Connectivity with Domain Name/Website
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=3.79 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=3.58 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=4.89 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=4 ttl=58 time=3.65 ms

--- itsmarttricks.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3496ms
rtt min/avg/max/mdev = 3.589/3.983/4.895/0.531 ms

Also Read : Best Linux Ifconfig Command With Examples

You can control the Packets of ping command and can mention how many Packets you want to send to Destination domain name or system by using the ping command with argument -cc is referred to as Count. Here I am sending 3 packets to the domain itsmarttricks.com. and after sending the mentioned number of packets the command will stop automatically.

[root@localhost ~]# ping -c 3 itsmarttricks.com  # To control Packets of ping command (ping utility )
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=3.58 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=3.66 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=3.91 ms

--- itsmarttricks.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2008ms
rtt min/avg/max/mdev = 3.586/3.720/3.916/0.157 ms

ping command with -i will keep Interval between two packets. i is referred to as Interval. For example, here I am Pinging to itsmarttricks.com and set 2 seconds of Interval between two packets. That means ping will send the first packet and wait for 2 seconds and then send the second packet like that the process will go on.

[root@localhost ~]# ping -i 2 itsmarttricks.com  # To keep interval between two packets
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=3.73 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=6.06 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=3.64 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=4 ttl=58 time=3.54 ms

--- itsmarttricks.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6649ms
rtt min/avg/max/mdev = 3.544/4.246/6.062/1.050 ms

Let’s take a Task to make your concept more clear: Here I am pinging to domain itsmarttricks.com and allowing Linux ping command to send 4 Packets with 3 Seconds of Interval between two Packets. Refer to the command below.

[root@localhost ~]# ping -c 4 -i 3 itsmarttricks.com
PING itsmarttricks.com (1103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=3.74 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=3.44 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=3.50 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=4 ttl=58 time=6.28 ms

--- itsmarttricks.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 9016ms
rtt min/avg/max/mdev = 3.448/4.245/6.282/1.181 ms

Normally the Packet Size of the Linux ping command (ping utility) is 56 Bytes or 64 Bytes (Highlighted in Red color). But you can set your own Packet size by using the ping command with argument -s.

[root@localhost ~]# ping itsmarttricks.com
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=3.97 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=7.68 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=4.60 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=4 ttl=58 time=4.80 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=5 ttl=58 time=19.4 ms
^C
--- itsmarttricks.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4386ms
rtt min/avg/max/mdev = 3.970/8.094/19.412/5.801 ms

# Refer the below command to Set your Packet Size :
[root@localhost ~]# ping -s 70 itsmarttricks.com   # To Set Packet Size
PING itsmarttricks.com (103.50.162.127) 70(98) bytes of data.
78 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=5.21 ms
78 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=7.02 ms
78 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=3.94 ms
78 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=4 ttl=58 time=8.94 ms
78 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=5 ttl=58 time=4.39 ms
^C
--- itsmarttricks.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4740ms
rtt min/avg/max/mdev = 3.947/5.905/8.942/1.849 ms

Linux ping command with -f will send the rapid packet requests to destination hosts i.e Hundred times faster than normal ping. In this kind of pinging you will not able to see any output. Ping command will show you the direct result when you stop the pinging. You can stop the pinging by using Keyboard Key i.e. CTRL+C. f is referred to as Flood. Here you can see on sample output below ping sends 1848 No’s of Packets within 7807 Mili Seconds.

[root@localhost ~]# ping -f itsmarttricks.com  # For Rapid Packet Transfer
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
.^C
--- itsmarttricks.com ping statistics ---
1848 packets transmitted, 1847 received, 0% packet loss, time 7807ms
rtt min/avg/max/mdev = 3.360/3.925/13.754/0.679 ms, pipe 2, ipg/ewma 4.227/3.762 ms

You are using the ping command with argument -w means you have set a deadline/timeout for ping command to stop the packet sending automatically. Here I have set a 3 Seconds as a deadline, which means the pinging will stop automatically after 3 seconds.

[root@localhost ~]# ping -w 3 itsmarttricks.com   # Set Deadline for ping command
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=1 ttl=58 time=4.04 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=2 ttl=58 time=4.12 ms
64 bytes from cp-in-9.webhostbox.net (103.50.162.127): icmp_seq=3 ttl=58 time=4.13 ms

--- itsmarttricks.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 4.048/4.105/4.139/0.040 ms

ping command with -q is for Silent Pinging or Quiet Pinging. It will show you the Result of the pinging when you stop it using CTRL+C.

[root@localhost ~]# ping -q itsmarttricks.com  # For Silent or Quiet Pinging
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
^C
--- itsmarttricks.com ping statistics ---
14 packets transmitted, 14 received, 0% packet loss, time 13428ms
rtt min/avg/max/mdev = 3.936/4.891/8.402/1.253 ms

you can use the Linux ping command with -n for Only Numerical Output.

[root@localhost ~]# ping -n itsmarttricks.com
PING itsmarttricks.com (103.50.162.127) 56(84) bytes of data.
64 bytes from 103.50.162.127: icmp_seq=1 ttl=58 time=8.51 ms
64 bytes from 103.50.162.127: icmp_seq=2 ttl=58 time=12.3 ms
64 bytes from 103.50.162.127: icmp_seq=3 ttl=58 time=19.1 ms
64 bytes from 103.50.162.127: icmp_seq=4 ttl=58 time=4.78 ms
64 bytes from 103.50.162.127: icmp_seq=5 ttl=58 time=5.78 ms
64 bytes from 103.50.162.127: icmp_seq=6 ttl=58 time=7.09 ms
^C
--- itsmarttricks.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5103ms
rtt min/avg/max/mdev = 4.789/9.608/19.114/4.886 ms

To check the installed Linux ping command Package version we can use the ping command with argument -V.

[root@localhost ~]# ping -V  # To check Installed ping command Package Version
ping utility, iputils-sss20071127

For more Linux ping command related arguments and options refer to the below command.

[root@localhost ~]# ping -help   # For more Linux ping command Related Options
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
            [-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
            [-M mtu discovery hint] [-S sndbuf]
            [ -T timestamp option ] [ -Q tos ] [hop1 ...] destination

You can refer to the man page of ping command for deep information related commands and theory.

[root@localhost ~]# man ping   # To Refer man page/help page of ping

We tried to include as much Linux ping Command (ping utility) with Examples. If something missed out then please comment in the comment box below so that we can include it in the article.

That’s all, In this article, we have explained the Most Useful Linux Ping Command (Ping Utility) With Examples. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.

Share this:

Mangesh Dhulap

This is Mangesh Dhulap the Founder and Editor of IT SMART TRICKS have 6+ years of Industrial Experience. We expect from our visitors to like, share, and comment on our posts.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.