The ping Command
The ping
command is a network utility that is used to test the reachability of a network host. It sends Internet Control Message Protocol (ICMP) echo request packets and evaluates the responses. If the destination host responds, the ping
command will display the round-trip time (RTT) of the packets in milliseconds. If the destination host does not respond, the ping
command will display a “Request timed out” message.
Syntax
The basic syntax for the ping
command is as follows:
ping [options] <destination_host>
The <destination_host> argument is the hostname or IP address of the network host that you want to test the reachability of. The [options] argument is a list of options that can be used to modify the behavior of the ping
command.
Examples
Ping the hostname “google.com”.
ping google.com
Ping the IP address “192.168.1.1”.
ping 192.168.1.1
Ping the hostname “google.com” for 10 packets.
ping -c 10 google.com
Ping the hostname “google.com” with an interval of 1 second.
ping -i 1 google.com
Options
The ping
command has a number of options that can be used to modify its behavior. Some of the most common options are:
-c : Ping the destination host for the specified number of packets.
-i : Ping the destination host at the specified interval in seconds.
-a: Ping the destination host continuously until you press Ctrl+C.
For more information on the ping
command and its options, please see the man page: man ping
.
With gencmd
gencmd ping google.com 3 times with an interval of 3 seconds
- ping -c 3 -i 3 google.com
- ping -i 3 google.com -c 3