Most useful Linux ping command (ping utility) with examples

This article shows you how to use the Linux ping command, also known as the ping utility. PING stands for Pbucket IInternet Network Groper is a network-related tool that can be used to check network connectivity between two systems using the IP address or host name, e.g. B. between two servers or two clients or between two devices that are in the network. For this purpose, Ping uses ICMP (Internet Control Message Protocol) to transmit and receive the packets between two devices. In simple words, the ping command is used to troubleshoot the network. The ping command was invented in 1983 by Sir Mike Muuss.

Most useful Linux ping command (ping utility) with examples

Follow the following article for the Linux ping command (ping utility) with examples:

The syntax for using the Linux ping command is:

Ring [OPTIONS] [Hostname/IP Address]

To check network connectivity between a system or network device (Router, server, etc.) We can use the ping command. Here I check the connectivity of one of my desktop systems with the IP address 192.168.1.103 and as shown in the issue below, I have positive connectivity.

[[email protected] ~]# 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 localhost or your own system, use the following ping command.

[[email protected] ~]# 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 to any domain name or website using the ping command (ping utility). Here I check the connectivity with my own website, i. H. Itsmarttricks.com.

[[email protected] ~]# 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

Read also: Best Linux Ifconfig command with examples

You can control the ping packets command and specify how many packets you want to send to the target domain name or system by using the ping command with an argument -c, c is called a count. Here I send 3 packets to the domain itsmarttricks.com, and after sending the specified number of packets, the command stops automatically.

[[email protected] ~]# 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 The interval between two packets is maintained. I is called the interval. For example, I ping here on itsmarttricks.com and set a 2 second interval between two packages. This means that ping sends the first packet and waits 2 seconds and then sends the second packet so that the process continues.

[[email protected] ~]# 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 clearer: Here I ping the domain itsmarttricks.com and allow the Linux ping command to send 4 packets with an interval of 3 seconds between two packets. See the following command.

[[email protected] ~]# 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

Typically, the packet size of the Linux ping command (ping utility) is 56 bytes or 64 bytes (Highlighted in red color). However, you can set your own package size using the ping with argument command -s,

[[email protected] ~]# 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 :
[[email protected] ~]# 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 sends the fast packet requests to target hosts, i.e. H. a hundred times faster than normal ping. You cannot see any output with this type of ping. The ping command shows the immediate result when you stop the ping. You can ping the keyboard key, i.e. H. CTRL + C, stop. f is called the flood. Here is an example of the output under ping sends 1848 number of packages within 7807 milliseconds,

[[email protected] ~]# 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 use the ping command with an argument -w means that you have set a ping deadline to stop the packet from automatically sending. Here I have set a deadline of 3 seconds, which means that the ping is automatically ended after 3 seconds.

[[email protected] ~]# 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 soft ping or soft ping. The result of the ping is displayed when you end it with CTRL + C.

[[email protected] ~]# 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 numeric output only.

[[email protected] ~]# 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 version of the Linux ping command installed, we can use the ping command with an argument -V,

[[email protected] ~]# ping -V  # To check Installed ping command Package Version
ping utility, iputils-sss20071127

For additional arguments and options for the Linux ping command, see the following command.

[[email protected] ~]# 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

For detailed information on commands and theory, see the ping command man page.

[[email protected] ~]# man ping   # To Refer man page/help page of ping

We tried to include as much Linux as possible Ring Command (ping utility) with examples. If something is missed, please comment it in the comment box below so we can include it in the article.

That’s all. In this article, we have used examples to explain the most useful Linux ping command (ping utility). I hope you like this article. If you like this article, just share it. If you have any questions about this article, please comment.

Sidebar