Quick take: The ping command tests whether a host is reachable and how fast it responds. ping host sends packets continuously; add -c 4 to send just four. The output shows round-trip time and any packet loss.

Introduction

The ping command is the first tool everyone reaches for to check connectivity. It sends ICMP echo requests to a host and times the replies, telling you whether the host is reachable, how fast it responds, and whether any packets are lost — the basics of network troubleshooting.

This guide covers running ping with a fixed count, tuning interval and packet size, and interpreting the results to distinguish a down host from DNS or latency problems.

Syntax

The basic syntax of the ping command is:

ping [OPTIONS] HOST

Common Options and Parameters

The most useful options and parameters for the ping command:

OptionDescription
-c NSend N packets, then stop.
-i SECSSet the interval between packets.
-s SIZESet the packet payload size in bytes.
-W SECSTimeout to wait for each reply.
-t TTLSet the IP time-to-live.
-4 / -6Force IPv4 or IPv6.
-qQuiet — show only the summary.

Practical Examples

Real ping commands you can run today:

# Ping a host (Ctrl+C to stop)
ping google.com
# Send exactly 4 packets
ping -c 4 google.com
# Ping faster, every 0.2 seconds
ping -i 0.2 -c 10 8.8.8.8
# Test with larger packets
ping -s 1400 -c 4 example.com
# Quiet summary only
ping -q -c 100 example.com
# Force IPv4
ping -4 -c 4 example.com

Tips and Best Practices

  • If ping to an IP works but a domain name fails, the problem is DNS, not connectivity — test with ping 8.8.8.8 versus ping google.com.
  • On Linux, plain ping runs continuously until you press Ctrl+C — use -c N in scripts so it terminates.
  • Watch the packet loss percentage and time values; loss points to a flaky link, high times to latency.

Final Thoughts

ping answers the most basic network question — “can I reach this host, and how fast?” Use -c to bound the test, compare an IP against a hostname to isolate DNS issues, and read packet loss and round-trip time to gauge link health. It is the natural first step before deeper tools like traceroute and dig.

FAQ: ping Command in Linux

How do I ping a host a specific number of times?+

Use -c: ping -c 4 example.com sends four packets and then stops with a summary. On Linux, ping otherwise runs until you press Ctrl+C.

What does ping tell me?+

It shows whether a host replies, the round-trip time for each packet, and the percentage of packets lost. Replies mean the host is reachable; loss or high times indicate network problems.

Why can I ping an IP but not a domain name?+

If ping 8.8.8.8 works but ping google.com fails, the network is fine but DNS resolution is broken. Check your /etc/resolv.conf and DNS settings, or test with dig.

How do I stop ping in Linux?+

Press Ctrl+C. On Linux ping runs continuously by default, unlike Windows which sends four packets and stops. Use -c N to limit it.

Why does ping fail even though a website loads?+

Some hosts and firewalls block ICMP echo requests, so ping times out even though the server is up and serving traffic. Try connecting to the actual service port with curl or nc instead.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support