Skip to content

ping Linux command

The Linux ping command is a simple yet powerful tool used to test the connectivity and latency of network devices. It sends ICMP packets to a specified destination and waits for a response, allowing you to determine if the device is reachable and how long it takes for packets to travel round-trip. Ping can be used to troubleshoot network issues, check the status of a network connection, and measure packet loss and delay. It is a valuable tool for network administrators and regular users alike, providing essential information about the health and performance of a network. Use the ping command with different options and parameters to customize the testing process and gather specific data for analysis.

ping Syntax:

Terminal window
ping [options] destination

Options:

OptionDescription
-cStop after sending count packets
-tSet the Time to Live
-iWait between sending each packet
-WTime to wait for a response
-qQuiet output
-sSpecify the packet size

Parameters:

ParameterDescription
destinationThe destination to ping

ping bash Examples:

Ping a Specific IP Address

Terminal window
ping 192.168.1.1

Pings the specific IP address “192.168.1.1” to test network connectivity.

Ping with a Specific Number of Packets

Terminal window
ping -c 5 8.8.8.8

Sends 5 ICMP echo request packets to the IP address 8.8.8.8.

Ping Continuously

Terminal window
ping -c google.com

Pings the domain name “google.com” continuously until manually stopped with Ctrl + C.

Ping with a Timeout

Terminal window
ping -w 3 facebook.com

Pings the domain name “facebook.com” with a timeout of 3 seconds for each packet.

Ping with Timestamps

Terminal window
ping -D yahoo.com

Pings the domain name “yahoo.com” and displays timestamps for each packet.

Ping with Quiet Output

Terminal window
ping -q amazon.com

Pings the domain name “amazon.com” and displays only summary statistics at the end.

ping Command Help Center:

How do I use ping in Linux?

To use the ping command in Linux, execute the following command:

Terminal window
ping <hostname or IP address>

What is the purpose of the ping command in Linux?

The ping command is used to test the reachability of a host on an IP network.

How can I set the number of packets to be sent using ping in Linux?

To set the number of packets to be sent, use the following command:

Terminal window
ping -c <count> <hostname or IP address>

How do I specify the time interval between sending ping packets in Linux?

To set the time interval between sending packets, use the following command:

Terminal window
ping -i <interval> <hostname or IP address>

Can I stop ping after a certain number of packets are sent in Linux?

Yes, you can stop ping after a certain number of packets by using the count option. Once the specified number of packets have been sent, ping will automatically stop.

How do I set the size of the packets being sent with ping in Linux?

To set the size of the packets being sent, use the following command:

Terminal window
ping -s <size> <hostname or IP address>

How can I make ping resolve hostnames to IP addresses in Linux?

To make ping resolve hostnames to IP addresses, use the following command:

Terminal window
ping -a <hostname>

Is there a way to limit the number of hops ping takes in Linux?

Yes, you can limit the number of hops by setting the TTL (Time To Live) value. This controls the number of routers the packets can traverse. Use the following command:

Terminal window
ping -t <ttl> <hostname or IP address>

Applications of the ping command

  • Checking connectivity to a remote host
  • Testing network latency
  • Troubleshooting network issues
  • Determining packet loss
  • Diagnosing network congestion
  • Verifying DNS resolution