ping
Networking
Usage
ping -c <count> <host>Sends ICMP echo requests to see whether a host answers and how long it takes; no answer does not mean it is down, because plenty of firewalls drop ICMP while TCP works fine.
Common flags
| Flag | Meaning |
|---|---|
| -c 4 | Stop after four packets. Without it, ping runs until Ctrl+C. |
| -i 0.2 | Interval between packets; anything under 0.2s needs root. |
| -s 1472 | Payload size. With -M do on Linux this is how you find the MTU. |
| -W 1 | How long to wait for a reply: seconds on Linux, milliseconds on macOS. |
| -t 5 | Total seconds before giving up, on macOS/BSD (on Linux that flag is -w). |
| -4 / -6 | Force IPv4 or IPv6. |
Examples
ping -c 4 1.1.1.1Four packets to an address that does not need DNS to work.
ping -c 3 -s 1472 -M do 8.8.8.8Check whether 1500-byte packets survive the path (Linux).
When a connection fails, these narrow down how far it got — name not resolving, no route, or a blocked port.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does ping do?
Sends ICMP echo requests to see whether a host answers and how long it takes; no answer does not mean it is down, because plenty of firewalls drop ICMP while TCP works fine.
Q. How do I type it?
ping -c <count> <host> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man ping. This command sits under Networking.
Related commands
man page: man ping