Linux command: ping
Ask another computer for a reply
Imagine knocking on a door to see whether someone answers. ping does a similar check over a network: it sends a small test message to another computer and waits for a reply. The test helps show whether messages can travel there and back, and how long the round trip took. A reply confirms this test worked; it does not prove that a website, SSH server, or other application is accepting connections.
On Linux, ping sends an ICMP (Internet Control Message Protocol) Echo Request and waits for an Echo Reply. This bounded example sends four requests and waits up to two seconds for each reply:
ping -c 4 -W 2 <host-or-ip>
Replace <host-or-ip> with a host name or numeric address. On Linux iputils, -c 4 stops after four requests and -W 2 sets the reply wait in seconds. Use -4 or -6 to choose IPv4 or IPv6 when comparing address families. If you give a name, the computer must first look up its address; using a number checks the network path without that name lookup.
Read the results carefully
An Echo Reply shows that a response returned for that request. The reported time covers both directions and the target's time to respond, so it cannot measure just one network link. Packet loss means some requests did not receive a reply under the test conditions. Different times can result from load on the path or either computer, or from a route change. Running the same test again gives another sample; include when you ran it because network conditions can change.
No reply has several possible explanations. The target may be offline, the route may be broken, a firewall or network device may block ICMP, the answer may be lost on its return trip, or the target may limit Echo Replies. A failed ping therefore does not tell you which part failed. To check an application, use the kind of client it expects, such as an SSH connection, an HTTP request, or another service-specific tool.
On Linux iputils, ping returns status 0 if at least one reply arrives. It returns status 1 if none arrive, or if a packet count and overall deadline are both set but fewer than the requested replies arrive before that deadline. Status 2 reports other errors. A script can tell a missed-reply result from another error, but the status alone does not explain why replies were missing. Read the local ping(8) manual because other implementations can use different options or timing rules.
For a server name that fails, first check which address it resolves to. Then try the numeric address, compare IPv4 and IPv6 when both are relevant, inspect the route, and test the application itself. Include the address family, request count, packet loss, and time window when sharing the result.




