Linux ping Command: Test Host Reachability and Round-Trip Time

ping sends an ICMP Echo request to check whether there is a response and the round-trip time (RTT). It is the first step in checking network connectivity, but the absence of a response does not necessarily mean that the entire service is down.

What is the ping command?

The response time is the time it takes to go to the destination and return, and it varies depending on the transmission path, congestion, and priority policies. Some hosts and firewalls block or restrict ICMP. When running it with a DNS name, name resolution is also involved, so checking again with the IP address can help narrow down the cause.

Basic syntax

ping [options] destination

Installed implementations and options may vary by distribution. Check the description for the current system with man ping.

Examples

Limit on the number of responses

Send only four times and check the summary statistics.

ping -c 4 example.com

Check IPv4 route

Select the IPv4 address to check for a response.

ping -4 -c 4 example.com

Response wait time limit

Sets to avoid waiting too long for slow or blocked targets.

ping -c 4 -W 2 192.0.2.1

Reading Response Time and Loss Rate

ping checks basic reachability and round-trip time using ICMP Echo requests and replies. This is an example of checking the local loopback address twice.

ping -c 2 127.0.0.1

Example of summary output in a normal loopback environment:

2 packets transmitted, 2 received, 0% packet loss

The time= in the reply line is the round-trip time in milliseconds and varies with each run. Even if a remote target does not respond, it does not necessarily mean the server is down. ICMP may be blocked by a firewall or there may be issues along the route, so also check the service port and DNS status separately.

Main Options and Format

Options/Format Description
-c count Sends only the specified number of requests and then exits.
-4 / -6 Uses IPv4 or IPv6.
-W seconds Specifies the wait limit for each response.
-w seconds Specifies the total execution time.
-i seconds Specifies the request interval.

Precautions when using

Continuous high-frequency requests may burden the target system or network, so use only within the scope necessary for diagnostics. A 100% packet loss can be due to various causes such as ICMP blocking, DNS issues, or path failures. The actual service status should be checked separately for the specific port and protocol.

Frequently Asked Questions

If there is no response to ping, does it mean the server is down?

You cannot conclude that. Even if a firewall or policy blocks ICMP responses, web or SSH services may still be normal.

Official Documentation

The exact behavior of options and implementation differences can be found in the official documentation related to ping.

More in This Category
Linux gunzip Command: Decompress gzip Files

Linux gunzip Command: Decompress gzip Files

Learn how to decompress gzip Files with the Linux gunzip command, including practical examples, key options, and important precautions.

Linux Administration Memo: Essential Commands and System Checks

Linux Administration Memo: Essential Commands and System Checks

A compact Linux administration reference for checking system information, processes, storage, networking, users, permissions, services, and logs.

Linux man Command: Read Command Manual Pages

Linux man Command: Read Command Manual Pages

Learn how to use the Linux man command to find and read command manuals, sections, options, and related pages, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Learn how to inspect and Configure Network Interfaces and Routes with the Linux ip command, including practical examples, key options, and important precautions.

Linux Tutorial / How the Shell Runs Commands: ;, &&, ||, Aliases, and Environment Variables

Linux Tutorial / How the Shell Runs Commands: ;, &&, ||, Aliases, and Environment Variables

Learn how Bash resolves commands and uses exit status with ;, &&, and ||, then distinguish aliases, shell variables, and exported environment variables.

Linux fg Command: Bring a Shell Job to the Foreground

Linux fg Command: Bring a Shell Job to the Foreground

Learn how to bring a Shell Job to the Foreground with the Linux fg command, including practical examples, key options, and important precautions.

Linux cut Command: Extract Characters and Fields

Linux cut Command: Extract Characters and Fields

Learn how to extract Characters and Fields with the Linux cut command, including practical examples, key options, and important precautions.

Linux truncate Command: Shrink or Extend File Size

Linux truncate Command: Shrink or Extend File Size

Learn how to shrink or extend files with Linux truncate, adjust sizes relatively, match a reference file, and distinguish sparse logical size from disk usage.

Linux timedatectl Command: Check Time Zone and Time Synchronization

Linux timedatectl Command: Check Time Zone and Time Synchronization

Learn how to check Time Zone and Time Synchronization with the Linux timedatectl command, including practical examples, key options, and important precautions.

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Use pwd, ls, cd, and tree to find your current location, inspect directories, navigate paths, and check where each command takes you.