How to use Ping command.

How To Use Ping Command.

In this article, wee will explain how to use ping command.

ping is part of the iputils (or iputils-ping) package, which is pre-installed on nearly all Linux distributions. It is also available on Windows, macOS, and FreeBSD.


How to Use the Ping Command

The syntax for the ping command is as follows:


To better illustrate, how the ping command works let’s ping


The output will look something like this:

PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=63 time=0.527 ms
64 bytes from ( icmp_seq=2 ttl=63 time=0.637 ms
64 bytes from ( icmp_seq=3 ttl=63 time=0.577 ms
64 bytes from ( icmp_seq=4 ttl=63 time=0.573 ms
64 bytes from ( icmp_seq=5 ttl=63 time=0.610 ms
--- ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.527/0.584/0.637/0.048 ms


Specify the Number of Packets

As already mentioned, by default, ping will continue to send ICMP packages until it receives an interrupt signal. To specify the number of Echo Request packages to be sent after which ping will exit, use the -c option followed by the number of the packages:


For example, to ping only one time you would use:

ping -c 1


Specify the Source Interface

The default behavior of the ping command is to send ICMP packages via the default route. If you have multiple interfaces on your machine you can specify the source interface with the -I option:


The following command will ping using em2 as a source interface:

ping -I em2


Specify the Internet Protocol

When you run the ping command, it will use either IPv4 or IPv6, depending on your machine DNS settings.

To force ping to use IPv4, pass the -4 option, or use its alias ping4:



For IPv6, pass the -6 option or use ping6:




ping is a command-line network utility that allows you to test the IP-level connectivity of a given host on the network.

To view all available options of the ping command, type man ping in your terminal.