Menu
Coddy logo textTech

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 icon

Challenge

Easy

Send 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 -o prints just the matching text instead of the whole line.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground