Checking Connections
A network is a set of machines joined so they can talk. Ping checks the connection to one machine on the network.
Check this machine
Ping checks the connection to this machine. The replies show the time each one took.
$ ping -c 3 127.0.0.1One check
One try is enough when the machine answers fast.
$ ping -c 1 127.0.0.1Example
$ hostname
$ ping -c 3 127.0.0.1Key points
- Localhost is the name for this machine itself.
- A server is a machine that answers other machines.
- Ping sends a small message and waits for the reply.
- A packet is one small message on the network.
- Use ping -c 3 to send three packets.
- The time shows how long each reply took.
- Your times will differ from the times shown here.
- The same command with example.com checks a far-away machine.
In this example, hostname prints the name of this machine. Ping then sends three packets to the same machine. Each reply shows its time. The summary line shows three sent, three back, and no loss.
Note
A lost packet means the machine did not answer.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does ping -c 3 127.0.0.1 do?