A few of the equipment used in community management and pc diagnostics, the ping command stands proud as probably the most basic and widely-used. A command-line software to be had in nearly each running machine, ping serves as an important diagnostic instrument for community engineers, machine directors, or even curious tech fanatics.

The ping command sends small packets of knowledge to a specified IP deal with or host, and in go back, it expects to obtain a answer. Through doing so, it is helping customers decide if a community tool is reachable and offers precious details about the community’s reaction time and reliability. Whether or not you’re troubleshooting connectivity problems, tracking community efficiency, or simply beginning your adventure into community control, the ping command is a must-know.

Common syntax for ping command:

ping [IP-ADDRESS]
1. Specify the choice of packets
ping -c [number] [IP-Address]

Use the -c way to have the ping command robotically forestall after a undeniable choice of packets had been despatched.

Instance:

Whilst you run the ping command with the -c 5 way to ship 5 packets to the IP deal with 127.0.0.1, you’ll be expecting to look an output very similar to the next:

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of knowledge.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.056 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.059 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.057 ms

--- 127.0.0.1 ping statistics ---
5 packets transmitted, 5 gained, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.045/0.055/0.059/0.006 ms
2. Take a look at Localhost community
ping localhost

If you happen to’re having hassle connecting to a far flung pc or site, ping the localhost to be sure to’re attached.

Instance:

Whilst you execute the ping command with localhost, you’re necessarily pinging your personal gadget. Right here’s a pattern output you could see:

PING localhost (127.0.0.1) 56(84) bytes of knowledge.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.031 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.030 ms

--- localhost ping statistics ---
4 packets transmitted, 4 gained, 0% packet loss, time 2998ms
rtt min/avg/max/mdev = 0.030/0.031/0.033/0.001 ms
3. Ship pings just for a restricted time frame
ping -i [number] [IP-Address]

The -i choice units the timeout period in seconds prior to every packet is distributed.

Instance:

The command ping -i 5 127.0.0.1 will ship ICMP Echo Request packets to the loopback deal with 127.0.0.1 each 5 seconds. Right here’s a pattern output:

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of knowledge.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.039 ms
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 gained, 0% packet loss, time 15005ms
rtt min/avg/max/mdev = 0.035/0.038/0.040/0.007 ms

On this instance, every request has been spoke back to in not up to a millisecond, and no packets had been misplaced. The output would possibly range relying in your machine configuration and the present machine load.

4. Flood ping to focus on host
ping -f [IP-address]

The -f choice will ship the packets as rapid as imaginable. It will flood the community, so it’s regularly known as “flood ping.” It’s basically used for pressure checking out and will have to be used with warning.

For the reason that packets are despatched as rapid as imaginable, there is probably not detailed output like the standard ping. As a substitute, you’ll simply see a chain of dots, and backspaces could be revealed as packets are despatched and gained.

Instance:

An ordinary output may glance one thing like this:

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of knowledge.
..........................................................^C
--- 127.0.0.1 ping statistics ---
468751 packets transmitted, 468750 gained, 0% packet loss, time 330ms
rtt min/avg/max/mdev = 0.025/0.035/0.139/0.002 ms, pipe 2, ipg/ewma 0.182/0.037 ms

Notice that the ^C above represents urgent Ctrl + C to forestall the command. It’s essential to grasp that the flood choice does require root privileges, so you could want to run this command with sudo in case you’re no longer the basis person.

5. Trade ping packet measurement
ping -s [number] [IP-Address]

Use the -s way to build up the default packet measurement, you’ll ship mild and heavy packets.

Instance:

The command ping -s 1000 127.0.0.1 sends ICMP echo requests to the loopback deal with 127.0.0.1 with a packet measurement of 1000 bytes. Right here’s an instance of what the output may seem like:

PING 127.0.0.1 (127.0.0.1) 1000(1028) bytes of knowledge.
1008 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.050 ms
1008 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.054 ms
1008 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.050 ms
1008 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.054 ms
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 gained, 0% packet loss, time 3071ms
rtt min/avg/max/mdev = 0.050/0.052/0.054/0.002 ms
6. Show best the abstract traces
ping -q [IP-Address]

The -q choice outputs a unmarried line with the common ping data, adopted via the statistics.

Instance:

Whilst you run the ping command with the -q flag at the loopback deal with 127.0.0.1, it sends ICMP ECHO_REQUEST packets to community hosts. The -q flag makes the command run in “quiet” mode, the place it best shows the abstract statistics when completed. The output may glance one thing like this:

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of knowledge.

--- 127.0.0.1 ping statistics ---
10 packets transmitted, 10 gained, 0% packet loss, time 8999ms
rtt min/avg/max/mdev = 0.045/0.057/0.082/0.012 ms
7. Set Time Restrict for receiving programs
ping -w [seconds] [IP-Address]

This selection stops receiving ping output after a undeniable period of time.

Instance:

Whilst you run the ping command with the -w 10 way to the loopback deal with 127.0.0.1, it sends ICMP echo request packets to the deal with and waits as much as 10 seconds for the replies. Right here’s an instance output you could see:

PING 127.0.0.1 (127.0.0.1) 56(84) bytes of knowledge.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.041 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.041 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.038 ms
...
--- 127.0.0.1 ping statistics ---
10 packets transmitted, 10 gained, 0% packet loss, time 8999ms
rtt min/avg/max/mdev = 0.038/0.041/0.045/0.002 ms
Extra Linux instructions:
Listing Operations rmdir · cd · pwd · exa · ls
Document Operations cat · cp · dd · much less · contact · ln · rename · extra · head
Document Gadget Operations chown · mkfs · find
Networking ping · curl · wget · iptables · mtr
Seek and Textual content Processing in finding · grep · sed · whatis · ripgrep · fd · tldr
Gadget Knowledge and Control env · historical past · most sensible · who · htop · glances · lsof
Person and Consultation Control display · su · sudo · open

The put up Learn how to Use the Ping Command in Linux gave the impression first on Hongkiat.

WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-ping/

[ continue ]