Pinging in Linux

Ping in Linux, like in Windows, is mainly used to check if a remote host is available or not. A remote host can be a web server, your router or a system on your local network.

How Does Ping Work?

It actually sends small ICMP packets to the remote host and waits for a reply. If the host is enabled, you should see a response.

It’s like the sonar technology used on submarines. Submarines send pulses of sound and wait for the echo to come back.

So, how do you use Ping in Linux? What are the different parameters of the Ping command? Let me show you some of the common ways to use the Ping command.

It’s often useful to acquire a fast step of a network’s “real-world” efficiency. Pinging is a method in which you send out a predetermined quantity of information to a particular IP address by yourself network or on the Internet and then get the information back once again. The elapsed time in between the moment you send the data packet and get it back informs you how well the network is performing. A ping test is simple to carry out from any computer system that runs a variation of the Linux OS.

Pinging From Gnome

  1. Click the “System” menu on your Gnome panel. Pick “Administration” and then choose “Network Tools.”
  2. Select the “Ping” tab from the Network Tools dialog box. Type a URL into the search box, or type an IP address if you are testing a local connection on your network. Select either a minimal test of five attempts or a limitless number of attempts by clicking the matching radio button below the search bar.
  3. Press the “Enter” crucial or click the “Ping” button on the Network Tools dialog box to perform the test. Within a couple of seconds, you should see the results on your screen.
  4. Close the dialog box by pressing “Ctrl-Q” on your keyboard or clicking the “X” in the top corner of the window.

Pinging From the Command Line

  1. Open a terminal window, either by pressing “Ctrl-Alt-T” on your keyboard or clicking the “Applications” menu on the Gnome panel and then picking “Accessories” followed by “Terminal.”.
  2. Type the word “ping” (without quotes) at the command prompt. Then type a space, followed by the URL or IP address of the target site. Press “Enter.”.
  3. Wait until 5 to 10 returned packages are displayed on your screen, then press “Ctrl-C” to stop the procedure and check out the summary. Ping will display a minimum, maximum and average reaction time in milliseconds. You can also view each private reaction line by line.
  4. Type “Exit” at the timely to close the terminal window. Additionally, click the “X” in the top corner of the terminal window or press “Ctrl-Shift-Q” on your keyboard to quit.

Using the Ping Command in Linux

You can use the ping command with an IP address or a host name/URL.

Suppose we ping Google. It will send ICMP packets of 56 bytes to google.com.

ping command in Linux

You have to manually stop the ping command, otherwise it will keep running. You can use the Ctrl + C terminal shortcut to stop the ping command in Linux as we did in the example above.

When you stop the ping command, it presents you with a transmission summary. You can see statistics such as the number of ICMP packets transmitted, packets received, packets lost, etc.

Now that you know how to ping in Linux, let’s look at some other options for the ping command.

Send Only N Number of Packets

If you don’t want the ping command to run forever without manually stopping, you can use the -c option.

In doing so, you can specify the number of packets the ping command must send before it stops automatically.

ping command in Linux