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 host Command: Look Up DNS Names and Addresses

Linux host Command: Look Up DNS Names and Addresses

Learn how to look Up DNS Names and Addresses with the Linux host command, including practical examples, key options, and important precautions.

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Learn the difference between a terminal and a shell, read command syntax and output, and use Bash help tools through a short hands-on exercise.

Linux umount Command: Unmount a Filesystem Safely

Linux umount Command: Unmount a Filesystem Safely

Learn how to unmount a Filesystem Safely with the Linux umount command, including practical examples, key options, and important precautions.

Linux nice Command: Set a New Process's Scheduling Priority

Linux nice Command: Set a New Process's Scheduling Priority

Learn how to set a New Process's Scheduling Priority with the Linux nice command, including practical examples, key options, and important precautions.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.

Linux Tutorial / Find Files and Commands with find, locate, which, and whereis

Linux Tutorial / Find Files and Commands with find, locate, which, and whereis

Compare find and locate for file searches, then use which, whereis, and Bash type to distinguish executable paths from shell command resolution.

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Understand what PID and PPID mean, inspect parent-child process relationships with ps and pgrep, and safely terminate a process you started yourself.

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 realpath Command: Resolve Absolute and Canonical Paths

Linux realpath Command: Resolve Absolute and Canonical Paths

Learn how to use the Linux realpath command to resolve relative paths, symbolic links, and redundant path components, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux tmux Command: Detach and Reattach Terminal Sessions

Linux tmux Command: Detach and Reattach Terminal Sessions

Learn how to detach and Reattach Terminal Sessions with the Linux tmux command, including practical examples, key options, and important precautions.