Ping Command in Linux with Examples

Table of Contents
Ping Command is cross-platform and most popular utility used to troubleshoot network related problems. PING stands for Packet INternet Grouper mostly used for checking connectivity between two network nodes. Mainly used to check if the host is reachable or not.
By using this command you can check whether the host is active or not. If it’s active it will reply back otherwise the destination is inactive.
Basicaly Ping command sends ICMP packets to the destination server or host and then waists for a response. After receiving a response from the destination which is echo packets, it will again send packets to the destination.
Basic Syntax of Ping Command
Following is the basic syntax for Ping command:
ping [options] destination
Where,
options: Options which are given here.
destination: Destination website or the IP address.
Ping Command Examples
Following are the examples for ping
command in Linux.
1. Basic use of ping command
Let’s check if www.google.com
is reachable or not by sending ICMP packets. To stop receiving packates press Ctrl+c
:
ping www.google.com
The output should be:

In the above command, ping command starts to send ICMP packages to a destination IP address. Then prints the output responded by the destination server.
2. Change Interval Between Ping Packets
By using -i
option you can change the interval between two ping packets sent to the destination server. You can change the default interval using this option. For example, if you want to send packates after every 2 second then use below command:
ping -i 2 linux4one.com
The output should be:

You can see the above command pings the destination server after every 2 seconds. You should press CTRL+c
to stop pinging.
3. Limit Number of Packets
To limit the number of packets using the ping command -c
option is used. You can specify any number of packets to send to the destination server. It will automatically stop after completing sending the given number of packets. Here you may not need to press CTRL+c
to stop pinging.
For example, run below command to send only 4 packets to the destination server linux4one.com
and stop it:
ping -c 4 linux4one.com
The output should be:

4. Specify Packet Size
By default ping
command will send packets of size 56 bytes
. To change this packets size you can use -s
option.
Run below command to send packets of size 75 to destination server:
ping -s 75 127.0.0.1
The output should be:

5. Ping With Sound
Ping command can play a beep when a packet is received, by using -a
option. This option plays a beep each a packet is received.
Run below command to ping with beep:
ping -a www.google.com
Press Ctrl+c
to stop sending packets.
6. Specify Timeout for Ping
You can limit how much time the ping command should run using -w
option. It will exit or stop the ping command after the given time.
In below example, ping command will stop sending packets after 3.5 seconds
:
ping -w www.google.com
The output should be:

Flood network using Ping
You can also send more than 100 packets per second using ping
command. To do such things -f
option is used with the ping command. If this option can only be used with sudo
privileges.
For example, to send more than 100 packets per second you can use below command, remember to press Ctrl+c
to interrupt below command:
ping -f www.google.com
The output should be:

Conclusion
You have successfully learned Linux Ping command with examples. If you have any queries please don’t forget to comment below.
LATEST POSTS
-
How to Install Anaconda on Ubuntu 18.04
-
How to Install Yarn on CentOS 7
-
Secure Apache with Let’s Encrypt SSL on Debian 10
-
How to Show Line Numbers in Vim or Vi Text Editor
-
How to Install R on Debian 9
-
How to Disable SELinux on CentOS 7
-
How to Install Gradle on Debian 10
-
How to Install XAMPP on Manjaro 18
-
How to Install MariaDB 10 on Linux Mint 19
-
How to install Git on Ubuntu 18.04
-
How to Uninstall Programs from Ubuntu System
-
How to Install PostgreSQL on Debian 9