Updated: 4 November 2026 · Applies to: ping from iputils 20240905 on Debian 13 (all examples tested), iputils on Ubuntu 24.04 and 26.04, AlmaLinux and Rocky Linux 9 and 10; fping 5.1, nmap 7.95 and mtr 0.95; macOS and OpenBSD options from their manuals
To ping a host on Linux, run ping -c 4 example.com. It sends four ICMP echo requests, prints every reply with its round-trip time and ends with a summary. Without -c, Linux ping keeps going until you press Ctrl+C (Windows stops after four on its own). Every Linux example below was run on Debian 13 with the iputils ping that all major distributions ship.
$ ping -c 4 google.com PING google.com (142.251.219.46) 56(84) bytes of data. 64 bytes from ncsfoa-an-in-f14.1e100.net (142.251.219.46): icmp_seq=1 ttl=117 time=17.8 ms 64 bytes from ncsfoa-an-in-f14.1e100.net (142.251.219.46): icmp_seq=2 ttl=117 time=17.8 ms 64 bytes from ncsfoa-an-in-f14.1e100.net (142.251.219.46): icmp_seq=3 ttl=117 time=17.9 ms 64 bytes from ncsfoa-an-in-f14.1e100.net (142.251.219.46): icmp_seq=4 ttl=117 time=17.8 ms --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms rtt min/avg/max/mdev = 17.763/17.810/17.884/0.045 ms
Reading the output
- 56(84) bytes: 56 bytes of data, 84 with the 8-byte ICMP header and the 20-byte IPv4 header.
- icmp_seq: the number of each request. A gap in the numbers is a lost packet.
- ttl: the time to live left in the reply.
- time: the round-trip time to the host and back.
- mdev: how much the times vary. The ping manual explains that a high mdev means unstable latency, which slows bulk transfers and hurts voice calls.
ping: command not found on Debian or Ubuntu
On Debian and Ubuntu, ping is in the iputils-ping package. It has priority "important", so normal installs include it, but minimal images and containers often do not, and then the shell says ping: command not found. Install it:
sudo apt install iputils-ping # Debian, Ubuntu sudo dnf install iputils # AlmaLinux, Rocky Linux, RHEL, Fedora ping -V # check the version
We found iputils 20240905 on Debian 13 and AlmaLinux 10, and 20250605 on Ubuntu 26.04. The options are the same.
Linux ping options
-c 5: stop after 5 requests.-i 0.5: seconds between requests (default 1). Below 0.002 seconds needs root.-w 10: deadline: exit after 10 seconds, whatever happened.-W 2: wait up to 2 seconds for a reply when none arrive.-s 1000: bytes of data per packet (default 56).-t 64: the TTL (hop limit) of outgoing packets.-M do: set the Don't Fragment flag (see below).-q: quiet, print only the summary.-n: show numbers only, no reverse DNS lookups.-4or-6: force IPv4 or IPv6.-I eth0: send from this interface or source address.-D: print a Unix timestamp before each line.-O: printno answer yet for icmp_seq=Nfor each missing reply.-v: verbose output.-f,-l 5,-b: flood ping, send 5 packets without waiting (preload), allow pinging a broadcast address.
Run ping -h for the full list.
Ping with Don't Fragment (MTU test)
Linux ping uses -M do for the Don't Fragment flag. Combine it with -s to find the largest packet that passes without being split. 1472 bytes of data plus 28 bytes of headers is exactly 1500, the normal Ethernet MTU:
$ ping -M do -s 1472 -c 2 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 1472(1500) bytes of data. 1480 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=17.9 ms 1480 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=17.9 ms $ ping -M do -s 1473 -c 2 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 1473(1501) bytes of data. ping: sendmsg: Message too long ping: sendmsg: Message too long (statistics lines omitted)
"Message too long" means the packet is bigger than your own interface MTU. If small packets get replies but 1472 does not, a link on the way (often a VPN or tunnel) has a smaller MTU: lower -s until replies come back, and add 28 to get the path MTU. For IPv6 the headers are 48 bytes, so start at ping -6 -M do -s 1452.
More ping command examples
- Limit the time:
ping -w 3 -i 0.5 127.0.0.1sent 6 requests and stopped after 3 seconds. - Only the summary:
$ ping -c 3 -q 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. --- 8.8.8.8 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 73.497/74.471/75.247/0.728 ms
- Low TTL: the second router on the way answers instead of the target (router address replaced):
$ ping -c 2 -t 2 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. From 198.51.100.1 icmp_seq=1 Time to live exceeded From 198.51.100.1 icmp_seq=2 Time to live exceeded (statistics lines omitted)
- Verbose ping:
-vadds the socket details ping uses and, according to the manual, shows duplicate replies when you ping a multicast address. It does not dump packets:$ ping -v -c 2 127.0.0.1 ping: ai->ai_family: AF_INET, ai->ai_canonname: '127.0.0.1' PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.016 ms sock4.fd: 3 (socktype: SOCK_DGRAM), sock6.fd: 4 (socktype: SOCK_DGRAM), hints.ai_family: AF_UNSPEC 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.041 ms (statistics lines omitted)
For a more useful log, combine-D(timestamps) and-O(missed replies). - Flood ping (root, only on networks you own):
sudo ping -f -c 1000 127.0.0.1printed1000 packets transmitted, 1000 received, 0% packet loss, time 129ms. Each dot on screen is a request still waiting for a reply. - In scripts: ping exits with 0 when replies arrive, 1 when none arrive and 2 on other errors (for example
ping: nosuchhost.invalid: Name or service not known):ping -c 1 -W 2 192.0.2.10 > /dev/null && echo up || echo down
Ping scan: find the live hosts in a subnet
Plain ping checks one address. To ping a whole range (a ping sweep), use fping or nmap -sn. Install them with sudo apt install fping nmap on Debian and Ubuntu; on AlmaLinux and Rocky, nmap is in the main repositories and fping is in EPEL. On our test network, two of the six addresses answered:
$ fping -a -g 192.0.2.0/29 2>/dev/null 192.0.2.1 192.0.2.4 $ sudo nmap -sn 192.0.2.0/29 (start line omitted) Nmap scan report for 192.0.2.1 Host is up. Nmap scan report for 192.0.2.4 Host is up. Nmap done: 8 IP addresses (2 hosts up) scanned in 1.59 seconds
-a shows only live hosts and -g generates the list from the subnet; see fping: ping many hosts at once. According to the Nmap manual, -sn run as root also sends TCP probes to ports 443 and 80 and uses ARP on the local network, so it finds hosts that block ping. Without extra tools, a Bash loop works too:
for i in $(seq 1 6); do ping -c 1 -W 1 192.0.2.$i &>/dev/null && echo "192.0.2.$i is up"; done
Scan only networks you manage. A host that does not answer may simply block ICMP: see how to disable ping responses.
pathping for Linux: use mtr
pathping is a Windows command that, according to Microsoft, reports latency and loss at every router between you and the target. Linux has no pathping; mtr does the same job (sudo apt install mtr-tiny or sudo dnf install mtr):
$ mtr --report -c 10 -n 8.8.8.8 HOST: vps Loss% Snt Last Avg Best Wrst StDev (one line per hop follows; shortened)
Each line below that header is one hop. Loss that starts at one hop and continues to the end points at that hop. See how to diagnose network issues with MTR and how to use traceroute.
ping on Unix: macOS and BSD options differ
The ping command on macOS and the BSDs is a different program, so some flags change meaning:
- Don't Fragment:
-Don macOS and OpenBSD (ping -D -s 1472 -c 3 example.com), not-M do. - TTL:
-mon macOS;-ton OpenBSD, as on Linux. - Timeout: on macOS
-tis the total run time in seconds and-Wwaits per reply in milliseconds. -c,-i,-s,-q,-nand-fwork as on Linux.
On Windows, see how to use the ping command on Windows.
Official documentation: ping(8) on Debian, OpenBSD ping and Nmap host discovery.