ping Test whether a host is reachable
Sends small test packets (ICMP echo requests) to a host and reports how long each reply takes. Use it to check that a machine is up and the network path works. On Linux and macOS it keeps going until you stop it, so give it a count with -c.
Synopsis
ping -c COUNT [OPTION]... host
Common options
| Option or form | What it does |
|---|---|
-c COUNT | Stop after sending COUNT packets. Without it, ping runs until you press Ctrl+C on Linux and macOS |
-i SECONDS | Wait SECONDS between packets. The default is one second |
-t SECONDS | On macOS, give up after SECONDS in total. On Linux, -t sets the TTL instead |
-W MS | How long to wait for each reply. On macOS the value is in milliseconds. On Linux (iputils) it is in seconds |
-s SIZE | Set the size of the data in each packet, in bytes |
-q | Quiet output: show only the summary at the end |
-n | Show numeric addresses only, without looking up names |
Examples
ping -c 4 example.com
ping -c 1 192.0.2.10
ping -c 5 -i 2 example.com
ping -c 10 -q example.com
ping -c 3 -n 192.0.2.10
Notes
- On Linux and macOS ping never stops by itself. Always add -c N in scripts, or it will hang. Press Ctrl+C to stop it and print the summary. (Windows ping sends four packets by default.)
- No reply does not always mean the host is down. Many firewalls and servers drop ICMP on purpose.
- A reply proves that the host answers ICMP, not that a particular service such as a web server is working. Use curl for that.
- If ping works with an IP address but fails with a name, the problem is DNS. Use dig to look into it.
- Option details differ between systems, notably -W (milliseconds on macOS, seconds on Linux) and -t. Check man ping on your machine.
See also
Last reviewed 2026-10-07.