Back to the command reference

ping

NetworkBeginner In real Linux

Check whether a host is reachable

Name: ping: named after the sound of sonar

This command needs a real Linux system; you can practise it in real Linux mode.

Description

ping sends ICMP echo requests to a host and waits for replies, showing each round-trip time and, at the end, loss and latency statistics. It is the first step in checking connectivity.

Some servers and firewalls block ICMP, so no reply doesn't always mean the host is down.

Syntax

ping [OPTION]... HOST

Common options

-c COUNTSend N packets (Linux pings forever otherwise; Ctrl+C stops)
-i INTERVALSeconds between packets
-W TIMEOUTWait at most TIMEOUT seconds for each reply
-w DEADLINEStop after DEADLINE seconds, whatever was sent
-s SIZEBytes of data per packet (56 by default)
-qQuiet: only the summary
-nDo not look up host names
-4 / -6IPv4 / IPv6 only

Examples

  • $ ping -c 4 web01

    Send 4 packets to web01; check latency and loss

    Explain
  • $ ping -c 3 127.0.1.20

    Use an IP address directly (db01)

    Explain

Related