ping command (Linux / bash / sh / zsh)
What it does
Test IP reachability and measure round-trip response time. When people search for the ping command linux network test, they usually want ping's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Test IP reachability and measure round-trip response time.
Syntax
ping [OPTION]... DESTINATION
Common options
| Flag / option | Meaning |
|---|---|
| -c COUNT | Stop after a fixed number of replies. |
| -i SECONDS | Set the interval between requests. |
| -W SECONDS | Set per-reply timeout. |
| -4 | Use IPv4 only. |
Practical examples
Four probes
ping -c 4 example.com
Sends four ICMP echo requests.
Short timeout
ping -c 3 -W 2 192.0.2.10
Limits each reply wait to two seconds.
IPv4 test
ping -4 -c 4 example.com
Forces IPv4 name resolution and probes.
Linux ↔ Windows equivalent
Closest match: ping (Windows / CMD). Test reachability and measure response time with ICMP echo requests.
Common mistakes
- Treating blocked ICMP as proof that a host or application is down.
- Leaving ping running indefinitely in scripts without `-c` or an external timeout.
Related commands
- tracerouteTrace the network hops taken toward a destination.
- ssInspect network sockets, listeners, and connection statistics.
- pingTest reachability and measure response time with ICMP echo requests.
- ipconfigDisplay and manage Windows IP configuration and DNS client state.
- curlTransfer data to or from URLs using many network protocols.
- sshOpen a secure remote shell or run a command over SSH.
- Invoke-WebRequestSend HTTP and HTTPS requests and return response metadata and content.
- netstatDisplay active connections, listening ports, routing data, and protocol statistics.
FAQ
What does ping do in Linux?
Test IP reachability and measure round-trip response time.
How do I use ping from the terminal?
Start with `ping [OPTION]... DESTINATION`, then choose only the options needed for the task.
What is a practical ping example?
Try `ping -c 4 example.com` — Sends four ICMP echo requests.
Can I use ping in a shell script?
Yes. ping works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.