Network and remote access

Command ping

Check host availability

Linux · Bash examples · commands run on the selected server

When to use ping

Use ping to test ICMP reachability and approximate round-trip timing. Limit the probe count for diagnostics and do not equate an ICMP result with the health of a particular application port.

Syntax

ping [PARAMETERS] NODE

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-c N
Limit the number of requests.
-W N
Waiting for a response in seconds in iputils ping.
-4 / -6
Select IPv4 or IPv6.

Usage examples

Check availability with limited requests

ping -c 4 example.com

Four probes are sent and a summary reports replies, loss and timing.

Check IPv4

ping -4 -c 3 example.com

The lookup and probes are restricted to IPv4.

Check local interface

ping -c 2 127.0.0.1

The loopback address tests a local networking path rather than an external route.

Notes and limitations

  • Lack of response does not prove that the application is unavailable: ICMP may be blocked.
  • To test a specific service, use nc or the appropriate protocol client.

Common questions and troubleshooting

Does a failed ping mean the server is offline?

Not necessarily. ICMP can be filtered or rate-limited while SSH or HTTPS still works. Test the intended application endpoint.

Does a successful ping prove SSH is working?

No. Ping does not authenticate, negotiate SSH or check a TCP listening port. Follow with an actual service-specific check.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man ping.