How To Use The ping Command (in Windows, Mac, and Linux)


Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, you will not only learn how to use the ping command to get the IP address of a website or server, but also some other cool tips and tricks that you can do with ping. This tutorial will work for Windows, Mac, and Unix operating systems.

  • Windows: open Command Prompt
  • Mac and Linux: open Terminal

Below are a handful of different examples of the ping command. Regardless of what operating system you use, all ping commands and arguments should be the same.

1. Basic ping Command

Let’s do a simple ping to the Google domain name to find the IP address.


Please note that this command will run indefinitely. To stop pinging, on Mac type Command + C and on Windows type Ctrl + C.

Example of ping command with IP addressPin

2. Ping an IP Address

You can also ping an IP address to test internet connectivity. A useful tip is to ping a well-known DNS server.


3. Ping at an Interval

By default, ping executes every 1 second. You can specify an interval to ping at with the -i flag.

ping -i 5
ping -i 0.1

4. Ping Your localhost

Sometimes it can be useful to ping your own local host. You can do this by name or IP address.

ping localhost

5. Stop Pinging After a Count

By default, ping will execute indefinitely until you interrupt it. To stop pinging after a certain number of times, you can use the -c flag. The following will ping for a count of 3 then stop.

ping -c 3

6. Ping with an Audible Beep

The -a flag will will play an audible sound when the ping command executes.

ping -a

7. Change Ping Packet Size

The default ping packet size is 64 bytes. This includes an 8 byte header. You can specify the packet size with the -s flag. The following will create a packet of size 108 bytes which includes the header.

ping -s 100 localhost

Here is a video demonstration of the ping command.

YouTube video

Meet Tony

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

Leave a Comment