Open In App

How to ping an Ip on windows macos and Linux

Last Updated : 10 Oct, 2023
Like Article

Ping is a command line networking utility that uses ICMP packets to check if a logical route is available to communicate with a specific host. A failure of the ping command doesn’t necessarily mean that the host is down. There are many other possible reasons for the failure. Along with the primary purpose of ping, this command can also provide insights about some of the useful networking parameters, such as Round Trip Time (RTT). Ping is available by default in all three operating systems. So, usually, you don’t need any prerequisites for executing this command.

The term ‘ping‘, in computer terms, refers to sending a message to a host to check if the host is up (alive and running) or down (dead). For simplification, think of ping as a message that contains the question ‘Hey, are you there?’. This might sound simple, but it is one of the handy commands still used by network engineers to troubleshoot various network issues. In this article, we will learn how to ping a host using its IP address, from the top 3 operating systems – Windows, Mac OS, and Linux.

Syntax of ‘ping’ command

The syntax of ‘ping’ command is OS-independent, which means, you can use the same syntax in different operating systems. However, certain options might change.

ping <IP_address/Host_name/Domain_name of host machine>

You can provide any one of the following to identify the host:-

  • IP address of host machine
  • The hostname of the machine
  • Domain name of the host (could be a web server in this case)

Options available with ping

I have provided the frequently used options of the ping command in the table below:-



-v (only in Linux or MacOS)

Provides verbal support to the user while executing the command.

-t (only in Windows)

Continuously send packets till a kill signal is received through keyboard interrupt.

-c (in Linux or MacOS)

-n (in Windows)

To specify the number of packets to be sent.

-W (in Linux or MacOS)

-w (in Windows)

Sets waiting time while receiving packets (in seconds).


Forces ping to use IPv4 addresses only.


Forces ping to use IPv6 only.

-t (in Linux or MacOS)

-i (in Windows)

To specify TTL(Time To Live) for the IP packets.

-h (only in Linux or MacOS)

To get help regarding the usage of the command.

-s (in Linux or MacOS)

-l (in Windows)

To specify the size of ping packet to be sent.

Note: For the options that work only in a specific OS, the details are provided within curved brackets. If no specification is provided, then the option remains the same in all three operating systems.

Ping in windows

1. Opening the command prompt

To ping an IP address in windows OS, first you need to open the command prompt. You can do this by opening the ‘run’ dialog box first, by pressing the shortcut key ‘windows_key + r’.

This will open the ‘run’ dialog box.


Opening the command prompt in windows

Now, type ‘cmd’ in the ‘run’ dialog box and hit the ‘enter’ key.

This will open the command prompt.

2. Viewing the options for ping

Lets explore various options to be used with ping command in windows simply typing the name of the command ‘ping’ in the terminal and pressing ‘enter’.



ping in windows

As you can see in the above screenshot, there are number of options available to use with the ping command.

3. Executing ping

Let us test the ping command by pinging the google DNS server which has the IP address ‘’.



pinging the google DNS server

Ping in Linux

1. Opening the terminal

In Linux, all command line utilities are available in the terminal. To open terminal in Linux, use the shortcut key ‘ctrl+alt+t’.

2. Seeking help for ping

Before using a command, it is always advised to study about it first. Luckily, for Linux users, we have manuals for every standard commands in the name of man pages. To view the manual of ‘ping’ command, enter the following in the terminal.

man ping


The man page provides a tons of information about the ‘ping’ command which includes the following:-

  • Synopsis (syntax) of the command
  • A brief description
  • Options available to use
  • Details of mentioning the interfaces while using IPv6 addresses with link-local scope
  • ICMP packet details
  • How ‘ping’ handles duplicate and damaged packets
  • Experimenting with different data patterns
  • TTL details
  • Bugs of the current version
  • History of ‘ping’
  • Security details and
  • Parent package of ping – iputils

3. Executing ping

Lets ping the web server in which the website with the domain name ‘practice.geeksforgeeks’ is hosted. In this example, instead of relying on the default count value, we we are going to specify the count of packets to be sent, by ourselves. This can be easily done using the ‘-c’ option in Linux.

ping -c 3


pinging with a specific count in Linux

This command will send only 3 ICMP packets to the target host. We could specify any integer value as the count.

Note: You need to use a different option ‘-n’, instead of ‘-c’ to specify the count in Windows operating system.

Ping in Mac OS

Using the ‘ping’ command is very similar to using ‘ping’ in Linux as both the operating system uses the same shell – ‘zsh’. Some Linux distros may use the bash shell. However they only have minor changes between them.

1. Opening the terminal

To open the terminal in Mac OS, type ‘terminal’ in the search box at the top of the desktop.


Opening the terminal in Mac OS

Now, click on the terminal icon to open a new terminal.

2. Finding help

Just like Linux, you can use the ‘man’ command to check out the manual pages of ‘ping’ command in Mac OS. In case, man pages are not found in your Mac terminal, don’t panic. You have another simple way to find help – The good old ‘–help option.

ping --help


ping –help in Mac OS

3. Executing ping

Executing the command is just the same executing it in Linux. Let’s specify the count using ‘-c’ option and ping the same domain name – ‘’.

ping -c 3


ping in Mac OS

The statistics of the ‘ping’ command will get printed on the terminal once the process has been completed. You can also interrupt the ping process and force it to terminate using the shortcut key ‘command + c‘.


ping statistics in Mac OS

Details covered by ping statistics

  • Number of packets transmitted.
  • Number of packets received from the target host as a response.
  • Percentage of lost packets (packets that are not received).
  • RTT (Round Trip Time) – Minimum RTT, Maximum RTT, Average RTT and Population standard deviation (how far RTT of each packet deviates from the average RTT).


Q1. Is it okay to specify a domain name instead of IP address in the ping command ?


Yes, it is okay to do so. But your machine will have to perform one additional step, that is DNS resolution. If DNS resolution fails, ping will also fail.

Q2. Is there a way to run ping command in Windows, without opening command prompt?


Step1: Press ‘win+r‘ to open run dialogue box.

Step2: Type in the ping command that you want to execute, in the dialogue box, say ‘ping localhost’ and hit ‘enter’ key. Your ping command will get executed without the need of opening command prompt!


Executing ping from Run dialogue box

Q3. What are the common reasons behind the failure of ping command?


Ping command fails mainly due to two major reasons that are listed below:-

  • Your machine doesn’t have a route to reach the target machine. In this case, you need to check the connection between your machine and the target.
  • The target machine may be configured in such a way that it doesn’t respond to any ping requests or responds to requests only when it comes from certain pre determined hosts. This configuration is usually set for security reasons.

    Q4. How do I check connectivity using Ping command, when rate of data transfer is low?


    If you have a poor network connection, packets may get lost even if you are connected to a host. This is because the default waiting time is usually 1 second. If you suspect your connectivity to be slow, you can increase the wait time to more than a second, say 10 seconds.


    ping -w 10

    The above example works only in Linux and MacOS. You need to use -W option in windows.

    Q5. What is the size of a ping packet?


    The default size of ping packet is given below:-

    • In Windows – 32 bytes.
    • In Linux / MacOS – 64 bytes.

    This default size can be changed using the ‘-l’ option in windows and ‘-s’ option in Linux or MacOS.


    That is it, friends. I hope that one can get started with the ping command in all three major operating systems – Windows, Mac OS, and Linux after completely reading this article. Please note that this article helps you only to get started with the command. Feel free to explore the links of other Geeks for Geeks articles that I have provided along to way to gain in-depth knowledge about the command.

      Like Article
      Suggest improvement
      Share your thoughts in the comments

      Similar Reads