The complete guide to using the Linux ping command and interpreting the results

The ping command is extremely helpful for troubleshooting and testing network speed and connectivity issues in Linux. Ping works by sending packets of data to an IP address or hostname and reporting how long it takes to receive a response. You can use the results of a ping test to figure out whether a site or server is reachable, and if so, whether there's any packet loss slowing things down. This wikiHow tutorial will teach you how to run the ping command in a Linux terminal, and how to understand ping results and statistics.

Things You Should Know

  • The basic syntax for ping is ping <ip address>, where <ip address> is the address of another device.
  • To ping an iPv6 IP address instead of an iPv4 address, you'll use ping -6 <ip address>.
  • "Destination host unreachable" means the host is down or that there is no route from your Linux computer to that host.
  • "Request timed out" sometimes indicates problems on the remote computer or network, but could also just mean that there's a firewall blocking the connection.
Section 1 of 4:

How Ping Works

  1. 1
    The ping command works by sending small packets of data to a server or host and waiting for a reply. You can ping another computer on your network, a website, a printer, a smartphone, or any other location on the internet that has a hostname or IP address. The packets sent by ping include an ICMP ECHO_REQUEST, which is basically a request that says "reply if you get this."
  2. 2
    When the host receives the ping request, it will reply with echo packets. These replies contain lots of helpful information, including the amount of time it took for each packet to reach the destination, and whether any packets were lost along the way. This information is easy to interpret and super helpful for diagnosing network problems.
  3. Advertisement
Section 2 of 4:

How to Ping

  1. 1
    Open a Terminal window. You can do this on most versions of Linux, including Ubuntu, by pressing Ctr + Alt + T. You can also double-click the Terminal app icon in your app list.
  2. 2
    Run a basic ping. At the prompt, type ping followed by the IP address, hostname, or domain name that you want to test. When you press Enter, you'll see the echoed results as individual entries.
    • Basic ping examples:
      • To ping a website like Facebook, you'd type ping www.facebook.com or ping facebook.com.
      • To ping an IPv4 IP address, such as 10.0.0.1, you'd type ping 10.0.0.1.
      • To ping an IPv6 IP address, you'll add the -6 option. To ping Facebook's IPv6 address, you'd use ping -6 2a03:2880:f02c:13:face:b00c:0:3.
      • You can also ping your own computer (localhost) to make sure your network adapter is working property. To do this, you'd use ping localhost or ping 127.0.0.1.
      • For more ping examples, see Advanced Ping Examples.
  3. 3
    Press Ctrl+C to stop the ping. In Linux, the ping command will continue to display echo results until you stop the process with this keyboard shortcut. Once you stop the ping, you'll see a statistics summary of the ping right above the prompt.
  4. Advertisement
Section 3 of 4:

Understanding Ping Results

  1. 1
    Check the ping statistics. At the bottom of your ping replies, you'll see a section that says "(host or IP) ping statistics." In Linux, you'll find helpful information in this section, including:
    • Packets transmitted and packets received. For example, if you stopped the ping after sending 15 packets, you'll see "15 packets transmitted," followed by the number of packets received by the host.
      • Packets that are sent but not received indicate packet loss. If some packets are lost, you'll notice a slower or inconsistent connection between your computer and the host. For example, lag in games and sluggish downloads.
    • Percentage of packets lost. For example, if none of the packets were received by the host, you'll see "100% packet loss" in the reply. If 2 out of 4 were received, you'll see "50% packet loss."
      • Packet loss can be caused by many things, including network congestion, router problems, network hardware issues, and configuration issues on the remote server.[1]
      • If 100% of packets are lost, there might not actually be a problem. Some servers discard ICMP packets as a security measure to avoid ping flooding, a type of denial of service attack.
    • Round trip time (RTT). This tells you how long it took for each packet to be sent to the host, plus the amount of time it took for Linux to receive the reply in milliseconds (MS).[2]
      • RTT is shown as multiple values: The minimum RTT (the shortest amount of time), average RTT, MAX RTT (the longest), and then MDEV RTT (mean deviation).[3] You'll also see a "time" value, which tells you the total amount of time the entire process took from start to finish.
  2. 2
    Interpret ping errors. If you're pinging a server, you might encounter one of these errors:
    • Unknown host: If you're trying to ping host or domain name that cannot be resolved, you'll see this error. This could mean the host or domain does not exist, but also may mean the name cannot be translated into an IP address by your DNS servers.
    • Destination host unreachable: This error means your computer was unable to send any packets to the address. This could indicate a problem on your network, or somewhere on the internet between your own network and the remote host's.
    • Request timed out: In this case, the problem is definitely not related to your own computer or network. Your computer sent the ping request, but did not receive a reply. The host may not be online, there could be a network problem on the host's end, or the ping could've been blocked by the host's firewall.
    • Name or service not known: This error means the hostname or address you're trying to ping does not exist. If the host does exist, there's a problem with your network configuration.
  3. Advertisement
Section 4 of 4:

Advanced Ping Examples

  1. 1
    Specify the number of packets to send. As you know from your basic ping, Linux will ping the destination repeatedly until you stop the ping by pressing Ctrl + C. If you just want to do a quick ping test that ends on its own, you can specify the number of packets to send using the -c option.
    • For example, to send 5 packets to facebook.com, you'd use ping -c 5 facebook.com. The ping will stop on its own after 5 packets are sent and report the results.
    • As an alternative, you can use the -w option to stop the ping after a number of seconds instead of specifying the packet number. For example, to ping Facebook for 10 seconds and then display the results, you'd use ping -w 10 facebook.com.
  2. 2
    Change the interval between packets. By default, a ping waits one second between each packet sent. If you want to increase or decrease the time between packets sent, you can use the -i option with ping.[4]
    • To increase the wait to 3 seconds between packets in your ping to Facebook, you'd use ping -i 3 facebook.com.
    • To decrease the wait to half of one second, you'd use ping -i 0.5 facebook.com.
  3. 3
    Change the size of your packets. By default, ping packets are 56 bytes, which actually translates to 64 ICMP data bytes.[5] You can send larger or smaller packets using the -s option.
    • For example, if you're running into performance trouble on your own network, you can try to send larger packets to see if your traffic is throttled. To send 1000 bytes instead of the default, you'd use ping -s 1000 facebook.com.
  4. 4
    Do a ping flood to test your network's performance. A great way to see how your network performs under heavy load is to "flood" a device on your network with ping requests. This outputs packets as fast as they return or 100 times per second, whichever is greater.[6] You can do this using the -f option.
    • Proceed with caution, as a ping flood can overload your network.
    • Because you'll need root access to do a ping flood, you'll need to preface the command with sudo.
    • To perform a flood ping, use sudo ping -f <hostname>.
  5. 5
    Play a sound when a host is reachable. If you're testing a host and want to run a continuous ping until the host is reachable again, you can use the -a option.
    • For example, if the local IP address 10.0.0.2 is unreachable and you want to know when it comes back up, you'd use ping -a 10.0.0.2. Once the host is reachable, the ping will run normally and display the output.
  6. 6
    Skip the live echo responses and only display the summary. If you don't want to see the live results of your ping and only need the statistics, you can use the -q command. For example, ping -q facebook.com.
    • However, you won't see the statistics at all until you press Ctrl + C. Because of this, you'll usually use -q in conjunction with specifying the number of packets to send. A better way to use -q is with the -c flag, which allows you to specify the number of packets to send. For example:
      • ping -c 5 -q facebook.com.
      • In this example, you'll send 5 packets of data to Facebook only. Once the packets are sent and the echoes are received, the statistics will appear.
  7. Advertisement

Community Q&A

  • Question
    From root, can we ping others in Linux?
    Community Answer
    Community Answer
    Yes, in root or regular user you can.
  • Question
    How do I stop my machine from pinging other machines?
    Community Answer
    Community Answer
    In a command prompt, press "Ctrl + C" to end processes in a command line. If you are not actively doing it in a command line, see if your computer is connected to a network or VPN. If not, try to find which kind of device it's pinging and where it is located. If all else fails, either it's nothing or you are being watched/hacked.
  • Question
    How to stop a Linux Mint PC once you have used the ping command?
    Community Answer
    Community Answer
    Cntrl + C will stop the ping if you ever start it. You can do the same to stop just about any process in Linux if you started it via command.
Advertisement

Warnings

  • Not all websites will allow you to ping their true addresses, so your ping results might not always be accurate.
    ⧼thumbs_response⧽
Advertisement

About This Article

Nicole Levine, MFA
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 660,600 times.
How helpful is this?
Co-authors: 12
Updated: January 5, 2023
Views: 660,600
Categories: Linux
Article SummaryX

1. Press Ctrl+Alt+T to open the terminal.
2. Type "sudo ping -v" to install Ping Version
3. Type "Ping" followed by the website or IP address you want to ping.
4. Press Enter.

Did this summary help you?
Advertisement