pings.in Menu

Ping on Linux: six commands we ran

ping -c 4 and a host sends four pings, then a summary source. Six runs on our Debian 13 machine, iputils 20240905, 5 December 2026, as printed.

How do I ping four times?

-c sets the count source:

$ ping -c 4 one.one.one.one
PING one.one.one.one (1.1.1.1) 56(84) bytes of data.
64 bytes from one.one.one.one (1.1.1.1): icmp_seq=1 ttl=57 time=0.996 ms
64 bytes from one.one.one.one (1.1.1.1): icmp_seq=2 ttl=57 time=1.01 ms
64 bytes from one.one.one.one (1.1.1.1): icmp_seq=3 ttl=57 time=1.17 ms
64 bytes from one.one.one.one (1.1.1.1): icmp_seq=4 ttl=57 time=1.00 ms

--- one.one.one.one ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 0.996/1.043/1.165/0.070 ms

time= is each round trip; mdev is the population standard deviation source.

How do I ping faster?

-i sets the seconds between pings, one if not set source. Half a second:

$ ping -c 4 -i 0.5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=0.530 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=0.936 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=0.540 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=0.589 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 1549ms
rtt min/avg/max/mdev = 0.530/0.648/0.936/0.167 ms

How do I send bigger pings?

-s sets the data bytes: 56 if not set, plus the 8-byte ICMP header source. With 1,000, the replies are 1,008 bytes:

$ ping -c 3 -s 1000 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 1000(1028) bytes of data.
1008 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=1.52 ms
1008 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=1.02 ms
1008 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=1.22 ms

--- 1.1.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.020/1.254/1.518/0.204 ms

How do I see only the summary?

-q prints the summary lines and nothing else source:

$ ping -c 5 -q 9.9.9.9
PING 9.9.9.9 (9.9.9.9) 56(84) bytes of data.

--- 9.9.9.9 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4100ms
rtt min/avg/max/mdev = 0.553/0.595/0.669/0.040 ms

How do I ping over IPv6?

-6 uses IPv6 only source, -4 IPv4 only source. Our machine has no IPv6 route, and said so:

$ ping -6 -c 3 one.one.one.one
ping: connect: Network is unreachable

It exited with code 2, the code for an error source.

What happens when nothing answers?

-W sets the seconds to wait for an answer source. Nothing answered at this address:

$ ping -c 2 -W 2 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.

--- 192.0.2.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1007ms

No reply at all, so ping exited with code 1 source: a script can test that.

How do I stop it?

Ctrl-C sends SIGINT source, the interrupt from the keyboard source, and ping prints its summary source.