Linux ping Command

In the world of networking, the ability to check if a networked device is reachable is a basic requirement. One of the tools that can help us achieve this is the ping command. The ping command is a tool that sends a signal to a specified networked device, and then waits for a response. The ping command is available in almost all operating systems, including Linux.

What is ping Command in Linux?

The ping command in Linux is a utility that helps to test connectivity between two devices on a network. The ping command sends a request to a specified device and waits for a response. The response from the device helps us to determine whether the device is available or not. The ping command uses ICMP (Internet Control Message Protocol) packets to communicate with the target device.

Syntax of ping Command

The syntax of the ping command is as follows

ping [options] [destination]
  • Options Optional arguments that can be passed to the ping command to modify its behavior.

  • Destination The IP address or hostname of the device that we want to test connectivity with.

How It Works

When you execute a ping command, the following process occurs:

ping Command Process Flow Source Host Target Host ICMP Echo Request ICMP Echo Reply Statistics Display Round-trip time, packet loss

Basic Usage

The basic usage of the ping command is as follows

ping <destination>

This command will send ICMP packets to the specified destination and wait for a response. The ping command will continue to send ICMP packets until it receives a response or until it is stopped manually using Ctrl+C.

Example Output

$ ping google.com
PING google.com (142.250.191.14) 56(84) bytes of data.
64 bytes from lga25s62-in-f14.1e100.net (142.250.191.14): icmp_seq=1 ttl=118 time=12.3 ms
64 bytes from lga25s62-in-f14.1e100.net (142.250.191.14): icmp_seq=2 ttl=118 time=11.8 ms
64 bytes from lga25s62-in-f14.1e100.net (142.250.191.14): icmp_seq=3 ttl=118 time=12.1 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 11.846/12.067/12.289/0.181 ms

Common Options

Option Description Example
-c count Send specified number of packets ping -c 5 192.168.0.1
-i interval Set interval between packets (seconds) ping -i 2 192.168.0.1
-s size Set packet size in bytes ping -s 100 192.168.0.1
-t ttl Set Time To Live value ping -t 64 192.168.0.1
-q Quiet mode (summary only) ping -q -c 5 192.168.0.1
-v Verbose output ping -v 192.168.0.1

Examples

Basic Connectivity Test

ping 8.8.8.8

Tests connectivity to Google's DNS server.

Send Limited Number of Packets

ping -c 4 google.com

Sends exactly 4 ICMP packets and then stops.

Change Packet Interval

ping -i 0.5 192.168.1.1

Sends packets every 0.5 seconds (faster than default 1 second).

Large Packet Size Test

ping -s 1000 -c 3 192.168.1.1

Tests with 1000-byte packets to check for MTU issues.

Quiet Mode Summary

ping -q -c 10 google.com

Runs 10 pings and shows only the final statistics.

Understanding ping Output

  • icmp_seq Sequence number of the ICMP packet

  • ttl Time To Live, decreases with each network hop

  • time Round-trip time in milliseconds

  • packet loss Percentage of packets that did not return

  • rtt Round-trip time statistics (min/avg/max/standard deviation)

Common Use Cases

  • Network Troubleshooting Verify if a host is reachable

  • Latency Testing Measure network response times

  • DNS Resolution Test hostname to IP address resolution

  • Path MTU Discovery Find maximum packet size supported

Conclusion

The ping command is an essential networking tool for testing connectivity and measuring network performance. It uses ICMP packets to verify host reachability and provides valuable statistics about packet loss and response times. Understanding ping's various options allows network administrators to perform targeted diagnostics and troubleshoot connectivity issues effectively.

Updated on: 2026-03-17T09:01:38+05:30

14K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements