Skip to main content

Command referenceping

ping command (Linux / bash / sh / zsh)

Linuxbashshzshnetworkbeginner

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 / optionMeaning
-c COUNTStop after a fixed number of replies.
-i SECONDSSet the interval between requests.
-W SECONDSSet per-reply timeout.
-4Use 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.

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.