Linux command: ping

Quick startpingCommand, used to ping the network host

ThispingCommand to ping a specific network host on the local network or the Internet.

You can use it with grammarping <host>where is it<host>It can be a domain name or an IP address.

This is an example of

These commands send the request to the server, and the server returns a response.

pingBy default, requests will continue to be sent every second and will continue to run until you stop the request usingctrl-CUnless you pass the number of attempts-cOptions:ping -c 2

oncepingIf it stops, it will print some statistics about the results: the percentage of lost packets and statistics about network performance.

As you can see, the screen will display the host IP address and the time it took to return the response.

Not all servers support ping operation, in case the request times out:

Sometimes this is done deliberately to "hide" the server, or just to reduce the load. Ping packets can also be filtered by the firewall.

pinguseICMP protocol(Internet Control Message Protocol), a network layer protocol like TCP or UDP.

The request sends a packet containing the following content to the server:ECHO_REQUESTMessage, and the server returns aECHO_REPLYinformation. I will not go into details, but this is the basic concept.

Pinging the host helps to understand whether the host is reachable (assuming it is pinged) and how far it is in terms of time to return to you. Generally, the server is geographically closest to the server. Simple laws of physics will cause the distance to become longer, which will cause more delay to the cable, and therefore less time will be returned to you.

ThispingThis command can be used in Linux, macOS, WSL and wherever you have a UNIX environment

Download mine for freeLinux Command Manual

More cli tutorials: