ICMP and ping
Lesson 15 of 47 in Coddy's Networking with the Terminal course.
ping answers one question: is that machine there? It sends a tiny message called an echo request and waits for an echo reply. Those messages are not HTTP and have no port. They belong to a separate protocol called ICMP, whose whole job is carrying control and error messages between machines.
That is why ping tells you nothing about a website. It talks to the machine, not to any program running on it.
ping -c2 127.0.0.1-c2 sends exactly two and stops. Without it, ping runs until you interrupt it, which is fine at a real terminal and useless in a script.
The summary at the end is the part worth reading: how many were sent, how many came back, and the packet loss percentage. Zero loss means every message made the round trip.
Challenge
EasySend two messages and confirm both made it home.
Ping 127.0.0.1 exactly twice and print only the packet loss figure from the summary. Expected output:
0% packet loss
grep -oprints just the matching text instead of the whole line.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
4Is It Reachable?
ICMP and pingReading Ping OutputWhen Ping LiesRefused or Timed OutRecap: ReachabilityPractice on your own: Terminal playground