How to Use the Linux ping Command to Test Network Connectivity

The “Is It Down?” Panic

You are a junior IT technician. A frantic employee calls and says, “The company website is completely down! I can’t reach it!”

Panic sets in. What exactly is broken? Did the Apache web application crash? Did the database corrupt? Did the cloud hosting provider turn off the server because the credit card expired? Or did the employee just lose their Wi-Fi connection?

Before you spend three hours digging into complex application error logs, you must answer the most fundamental question in networking: Is the physical machine actually turned on and connected to the internet?

You answer this question using the oldest, simplest, and most reliable diagnostic tool in the Linux terminal: the ping command.

How Ping Works (The Digital Sonar)

The ping command acts exactly like submarine sonar. It does not care if your website is functioning. It does not care about databases or HTML. It operates at a fundamental network layer (ICMP).

When you use the command, your computer shouts a tiny digital packet of data (an “echo request”) across the internet to the target server. If the target server is turned on and connected to the network, it is biologically programmed by the internet protocol to shout back (an “echo reply”).

If you get a reply, the server is alive. The problem is your web software. If you get silence, the server is dead or unreachable.

Executing a Basic Ping Test

Open your Linux terminal. The syntax is incredibly simple. You just type ping followed by the domain name or the IP address of the server.

ping google.com

When you press Enter, Linux will immediately start sending packets. Unlike Windows, which stops after four pings, Linux will ping forever until you force it to stop.

You will see output that looks like this scrolling down your screen:

64 bytes from 142.250.190.46: icmp_seq=1 ttl=115 time=14.2 ms
64 bytes from 142.250.190.46: icmp_seq=2 ttl=115 time=13.8 ms
64 bytes from 142.250.190.46: icmp_seq=3 ttl=115 time=15.1 ms

To stop the command from running, you must press the interrupt shortcut on your keyboard: Ctrl + C.

How to Read the Output

When you press Ctrl + C, Linux stops the sonar and prints a summary. Here is how to interpret the data to diagnose your problem.

1. Packet Loss (The Reliability Test)

Look at the summary line: 10 packets transmitted, 10 received, 0% packet loss.

  • 0% Loss: The connection is perfect. If the user still cannot see the website, the web application software (like Apache or Nginx) has crashed. The hardware is fine.
  • 100% Loss: Your sonar hit a brick wall. The server is completely turned off, the ethernet cable is unplugged, or a strict firewall is blocking the traffic.
  • 20% Loss: This is a nightmare scenario. The server is alive, but the connection is highly unstable. You likely have a failing hardware router or severe network congestion dropping packets randomly.

2. Time (The Speed Test)

Look at the time=14.2 ms at the end of each line. This is the latency—exactly how many milliseconds it took for the data to travel to the server and back.

  • Under 50ms: Excellent. Fast and responsive.
  • 100ms – 200ms: Normal if the server is located on another continent.
  • Over 500ms (or erratic jumping): You have a severe latency issue. The network is bottlenecked. This explains why a user might complain the database is running incredibly slow, even if it hasn’t crashed.

The Pro Tip: Limiting the Count (-c)

Because Linux pings infinitely, professional admins use the -c (count) flag to tell the command exactly how many sonar pings to send before stopping automatically. This is especially useful if you are writing automated bash scripts.

To send exactly 5 pings and then stop, use:

ping -c 5 mycompanyserver.com

Conclusion

Do not start troubleshooting complex application logs until you have verified the foundation. By firing off a quick ping command, you can instantly determine whether you are dealing with a software crash, a dead piece of hardware, or a congested network.

Related posts

  1. Essential Linux Terminal Keyboard Shortcuts to Work Faster
  2. How to Find Large Files and Directories in Linux
  3. How to Create and Extract ZIP Files in the Linux Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.