FactorPad
Build a Better Process

Linux ping Command Summary with Examples

Linux ping allows you to send data packets to hosts.
  1. Purpose - Learn what ping is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with printf.
  4. A tip - Finish off with on more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux ping, 82 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / ping-command.html


An ad-free and cookie-free website.


Examples of the Linux ping command

Beginner

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux ping Command Summary with Examples (3:39)

Video Script

The Command and Why You Need It

Our eighty-second word, or command to memorize is ping from our category Communication.

ping allows you to send data packets to hosts.

Common Linux ping Options
-options description
-h, --help Print help screen
-c, --count=NUMBER Send specific NUMBER of packets
-w, --timeout=N Stop after N seconds

Recall from recent videos (tutorials) we tackled user topics and now we'll switch to the topic of system communication. In this video we'll send small packets of data over the Internet to a host that normally sends them back.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The ping command has 25 options, and the argument is the hostname. Host names can be in one of two forms, either human digestible like google.com, in Internet Protocol speak, like 24.58.108.13.

Like most commands, help is available with double-dash --help. You can limit the packets, with -c for a count, or -w for time.

We'll keep building on this conversation, but to start out just imagine these data packets traversing many hosts or computers, or routers, to the destination and back in fractions of a second.

So why is ping an important command? Well, if troubleshooting Internet connections at the command line is your goal, ping is often the easiest method. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. So let's go with ping optionless to factorpad.com.

$ ping factorpad.com PING factorpad.com (69.195.124.226): 56 data bytes 64 bytes from 69.195.124.226: icmp_seq=0 ttl=51 time=53.161 ms 64 bytes from 69.195.124.226: icmp_seq=1 ttl=51 time=52.625 ms 64 bytes from 69.195.124.226: icmp_seq=2 ttl=51 time=52.797 ms 64 bytes from 69.195.124.226: icmp_seq=3 ttl=51 time=52.750 ms 64 bytes from 69.195.124.226: icmp_seq=4 ttl=51 time=52.653 ms 64 bytes from 69.195.124.226: icmp_seq=5 ttl=51 time=52.679 ms 64 bytes from 69.195.124.226: icmp_seq=6 ttl=51 time=52.692 ms 64 bytes from 69.195.124.226: icmp_seq=7 ttl=51 time=52.688 ms ^C--- factorpad.com ping statistics --- 8 packets transmitted, 8 packets received, 0% packet loss round-trip min/avg/max/stddev = 52.625/52.756/53.161/0.161 ms

And notice how it keeps running, so in order to stop it, just like other programs that are running, use our old trusty Ctrl-c.

And then really all we need often is just a few so let's ping five times and this time use computer language using the IP address, just to see if that works.

$ ping -c 5 69.195.124.226 PING 69.195.124.226 (69.195.124.226): 56 data bytes 64 bytes from 69.195.124.226: icmp_seq=0 ttl=51 time=53.131 ms 64 bytes from 69.195.124.226: icmp_seq=1 ttl=51 time=52.772 ms 64 bytes from 69.195.124.226: icmp_seq=2 ttl=51 time=52.797 ms 64 bytes from 69.195.124.226: icmp_seq=3 ttl=51 time=52.793 ms 64 bytes from 69.195.124.226: icmp_seq=4 ttl=51 time=52.707 ms ^C--- factorpad.com ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max/stddev = 52.707/52.840/53.131/0.149 ms

It does, and last, because we like statistics here at FactorPad, average and standard you can see here. Let's run a ping for 10 seconds using -w.

$ ping -w 10 factorpad.com PING factorpad.com (69.195.124.226): 56 data bytes 64 bytes from 69.195.124.226: icmp_seq=0 ttl=51 time=53.247 ms 64 bytes from 69.195.124.226: icmp_seq=1 ttl=51 time=52.711 ms 64 bytes from 69.195.124.226: icmp_seq=2 ttl=51 time=52.802 ms 64 bytes from 69.195.124.226: icmp_seq=3 ttl=51 time=52.756 ms 64 bytes from 69.195.124.226: icmp_seq=4 ttl=51 time=52.711 ms 64 bytes from 69.195.124.226: icmp_seq=5 ttl=51 time=52.819 ms 64 bytes from 69.195.124.226: icmp_seq=6 ttl=51 time=52.754 ms 64 bytes from 69.195.124.226: icmp_seq=7 ttl=51 time=52.673 ms 64 bytes from 69.195.124.226: icmp_seq=8 ttl=51 time=52.687 ms 64 bytes from 69.195.124.226: icmp_seq=9 ttl=51 time=52.704 ms --- factorpad.com ping statistics --- 11 packets transmitted, 10 packets received, 9% packet loss round-trip min/avg/max/stddev = 52.673/52.786/53.247/0.160 ms

And then just looking at this, it looks very fast and the distribution looks quite tight.

A Final Tip

Okay now you know how to use ping. And you know the syntax for commands, options and arguments.

One last tip about the ping command. So since it is very important, find a link below to an article on Internet Communication Protocols (on Wikipedia).

Okay, thanks for visiting today. I hope this was a helpful introduction to the ping command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Join the smart crowd we're forming. Subscribe, join and tell a friend. Thank you.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / ping-command.html


linux ping command
ping command
linux ping examples
networking commands
ping linux
linux networking commands
ping ip
ping program
man ping
ping ip address
ping a website
ping command linux
ping internet
ping options
ping network
ping packet
ping time

A newly-updated free resource. Connect and refer a friend today.