Ping Command in Linux (original) (raw)

Last Updated : 11 Jun, 2026

The ping command is a network utility used to test the reachability of a host and measure the time it takes for packets to travel to and from that host. It helps diagnose network connectivity issues by sending ICMP Echo Request packets and analyzing the responses.

Example: Checking Internet Connection in Linux

To check internet connection, this command sends ICMP echo requests to google.com to check if the website is reachable and displays the response time for each packet.

**Command:

ping www.google.com

**Output:

The internet connection to www.google.com is working correctly with 0% packet loss, successful transmission and reception of 4 packets, and low round-trip time (RTT) values averaging 1.264 ms, indicating a responsive and stable connection.

testing internet connection using ping command

testing internet connection using ping command

Syntax

ping [OPTION]

PING Command Options

1. -c COUNT: Specifying the Number of Pings

Specifies the number of ICMP packets to send before stopping.

**Example: Send 2 ping requests

**Command:

ping -c 2 www.geeksforgeeks.org

**Output:

Specify the number of pings in Linux

Specify the number of pings in Linux

2. -s SIZE: Controlling Packet Size

Sets the size of the packet payload to be sent.

**Example: Send packets of size 40 bytes

**Command:

ping -s 40 -c 5 www.geeksforgeeks.org 

**Output:

3

3. -i INTERVAL: Changing the Time Interval Between Pings

Modifies the delay (in seconds) before sending the next packet.

**Example: Set interval to 2 seconds

**Command:

ping -i 2 www.geeksforgeeks.org

**Output:

Changing time interval in Ping Command

Changing time interval in Ping Command

4. -q: Showing Only Summary Output

Displays only the summary of the ping results.

**Example: Show summary for 5 packets

**Command:

ping -c 5 -q www.geeksforgeeks.org

**Output:

5. -w DEADLINE: Setting a Ping Timeout

Sets the total time (in seconds) ping should run.

**Example: Run ping for 3 seconds

This command instructs the system to stop pinging the specified website (www.geeksforgeeks.org) after waiting for 3 seconds.

**Command:

ping -w 3 www.geeksforgeeks.org

**Output:

6. -f: Flood Ping

Enables flood ping mode.

**Example: Flood ping a host

This command floods the network with PING packets directed at www.geeksforgeeks.org, providing a means to assess and test network performance.

**Command:

ping -f www.geeksforgeeks.org

**Output:

folding with ping

flooding with ping

7. -W TIMEOUT: Setting Maximum Wait Time for a Response

Sets the maximum time to wait for each reply.

**Example: Wait 3 seconds for each reply

This command configures the system to wait for a response for a maximum of 3 seconds while sending 5 PING requests to `www.geeksforgeeks.org\`.

**Command:

ping -c 5 -W 3 www.geeksforgeeks.org

**Output:

8. -p PATTERN: Filling Packets with Custom Data

Fills packets with a specific hexadecimal pattern.

**Example: Fill packets with ff

This command fills PING packets sent to `www.geeksforgeeks.org\` with the specified data, in this case, ones (represented by `ff`).

**Command:

ping -c 5 -p ff www.geeksforgeeks.org

**Output:

Fill Packet with Data

Fill Packet with Data

9. -M OPTION: Enabling Path MTU Discovery

Controls Path MTU Discovery behavior.

**Options:

**Example: Enable PMTU discovery

This command initiates Path MTU Discovery for the specified website (`www.geeksforgeeks.org\`) with the option to either prohibit fragmentation (`do`), perform PMTU discovery with local fragmentation when needed (`want`), or not set the DF flag (`dont`).

**Command:

ping -c 5 -M want www.geeksforgeeks.org

**Output:

Path Mtu Discovery

Path Mtu Discovery

Other Examples

Here are a few more examples to help you thoroughly understand the ping command and verify network connectivity:

1. Ping an IP Address

**Command:

ping 8.8.8.8

2. Ping a Host Only Once

**Command:

ping -c 1 google.com

3. Ping with Audible Alerts

**Command:

ping -a google.com

**Note : Beep may not be supported on all devices and Distributions