![]() |
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.
Syntax of ‘ping’ commandThe 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:-
Options available with pingI have provided the frequently used options of the ping command in the table below:-
Ping in windows1. Opening the command promptTo 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 pingLets 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 ![]() 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 pingLet us test the ping command by pinging the google DNS server which has the IP address ‘8.8.8.8’. ping 8.8.8.8 ![]() pinging the google DNS server Ping in Linux1. Opening the terminalIn 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 pingBefore 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:-
3. Executing pingLets ping the web server in which the website with the domain name ‘practice.horje’ 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 practice.horje.org ![]() 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.
Ping in Mac OSUsing 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 terminalTo 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 helpJust 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 pingExecuting the command is just the same executing it in Linux. Let’s specify the count using ‘-c’ option and ping the same domain name – ‘practice.horje.org’. ping -c 3 practice.horje.org ![]() 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
FAQsQ1. Is it okay to specify a domain name instead of IP address in the ping command ?Answer:
Q2. Is there a way to run ping command in Windows, without opening command prompt?Answer:
![]() Executing ping from Run dialogue box Q3. What are the common reasons behind the failure of ping command?Answer:
Q4. How do I check connectivity using Ping command, when rate of data transfer is low?Answer:
Q5. What is the size of a ping packet?Answer:
ConclusionThat 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. |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |