How to Ping a Server in Ubuntu Linux Using the ping Command

When a website won’t load or a remote server stops responding, the very first troubleshooting step any network administrator takes is to use the ping command. This fundamental utility sends a tiny packet of data (an ICMP Echo Request) across the internet to a specific destination and waits for a reply. It allows you to confirm whether the server is online, how long it takes for the data to travel back and forth, and whether any data packets are being lost along the way.

How to Use the Basic Ping Command

Using the command is incredibly straightforward. Open your Ubuntu Linux terminal and type the command followed by the domain name or the IP address you want to test:

ping google.com

Or, using an IP address:

ping 8.8.8.8

Press Enter. You will immediately see lines of text appearing on your screen, indicating that replies are being received.

How to Stop the Ping Command

In Windows, the ping command automatically stops after sending four packets. In Ubuntu Linux, the ping command runs indefinitely. If you do not stop it, it will continue sending packets to the server forever.

To force the command to stop, you must press the interrupt keyboard shortcut:

Ctrl + C

Once you press this, the terminal will stop sending packets and display a statistical summary of the test, including the total packets sent, packets received, packet loss percentage, and the average response time (latency).

How to Limit the Number of Pings

If you prefer the Windows-style behavior and only want to send a specific number of requests without having to manually press Ctrl + C, you can use the -c (count) flag.

To send exactly four pings and then stop automatically, type:

ping -c 4 google.com

The terminal will send four requests, print the summary, and return you to the command prompt.

Understanding the Output

When the command is running, each line of the output provides valuable information.

  • bytes: The size of the data packet sent (usually 64 bytes).
  • icmp_seq: The sequence number of the packet. If numbers skip (e.g., 1, 2, 4), it means packet 3 was lost in transit.
  • ttl: “Time to Live.” This number decreases every time the packet passes through a router. It prevents packets from bouncing around the internet forever.
  • time: This is your latency, measured in milliseconds (ms). It is the total round-trip time it took for your request to reach the server and the reply to reach your computer. Lower numbers indicate a faster, more responsive connection.

Get the best tech tips delivered straight to your inbox.

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