When web pages take an unusually long time to load, video conferencing calls stutter, or online games suffer from sudden lag spikes, pinpointing whether the fault lies with your local router, internet service provider (ISP), or the remote web server is the first diagnostic step. In Linux, the venerable ping utility remains the definitive command-line tool for assessing network health. By sending ICMP Echo Request packets and analysing round-trip responses, Ubuntu terminal users can instantly diagnose latency, packet loss, and network stability.
How the Ping Command Works in Linux
The ping command operates on the Internet Control Message Protocol (ICMP):
- Round-Trip Time (RTT): Measures the exact time in milliseconds (ms) for a packet of data to travel from your computer to the destination server and return.
- Packet Loss: Calculates the percentage of transmitted data packets that failed to return, indicating physical cable damage, severe Wi-Fi interference, or router buffer bloat.
- Continuous Execution: Unlike Windows, which sends only four ping packets by default and stops, Linux ping runs continuously until manually halted by the user or constrained by command flags.
How to Run Basic Ping Tests in Ubuntu
To launch network diagnostic tests in the Ubuntu terminal:
- Press
Ctrl + Alt + Ton your keyboard to open the terminal. - To test general internet connectivity and DNS resolution, ping a reliable public DNS server such as Cloudflare or Google:
ping 1.1.1.1 - The terminal will print a continuous live stream of return packets, displaying the sequence number (
icmp_seq), Time to Live (ttl), and response time in milliseconds (time=14.2 ms). - To stop the test, press
Ctrl + Con your physical keyboard. - Upon stopping, ping displays a comprehensive summary table showing transmitted packets, received packets, percentage packet loss, and min/avg/max/mdev round-trip latency.
Limiting Ping to a Specific Number of Packets
To avoid having to manually terminate the command with Ctrl + C, use the count flag (-c):
- To send exactly 5 test packets and automatically exit, run:
ping -c 5 google.com - The terminal transmits 5 packets, prints the summary statistics, and returns your prompt immediately. This syntax is especially useful when writing automated bash maintenance scripts.
Systematic Network Troubleshooting with Ping
When troubleshooting an internet disconnection, ping targets in logical outward stages to isolate the exact point of failure:
- Test Local TCP/IP Stack:
ping -c 3 127.0.0.1. If this succeeds, your local Linux networking hardware and kernel drivers are operating properly. - Test Local Router Gateway:
ping -c 3 192.168.1.1(or your specific router IP). If this fails, the issue is an unplugged Ethernet cable or Wi-Fi disconnection. - Test External Public IP:
ping -c 5 8.8.8.8. If this succeeds, your internet connection is live, but if pinging a domain name likegoogle.comfails, your issue is specifically broken DNS configuration.