Linux-Befehle

Ping command in Ubuntu 20.04

Ping command in Ubuntu 20.04
Ping stands for 'Packet Internet Groper' that helps the administrator to check the network connectivity status between the host and the destination source or computer.

Ping is also used to assess the total time it takes to packet send and receives an acknowledgment from the connected network. In this article, you will learn the basic uses of ping command in the Linux system. We have executed all the below mentioned commands on Ubuntu 20.04.

Syntax of the ping command

The basic syntax of the ping command is as follows:

$ ping host-name/IP

In the above syntax, the hostname is the name of the website or you can use the IP address.

To check your desired host-name is working or not in this case you need to type the following command in the terminal:

$ ping linuxhint.com

Use Ctrl + C from your keyboard to terminate the process.

Use of ping command with examples in Linux

The following uses of the ping command are given below:

Check local network using the ping command

Sometimes, you encounter problems in reaching the desired website. So, in this situation, you can ping your localhost or computer system to check the proper internet connection. The following commands are useful to check your local internet connection:

$ ping localhost

Or

$ ping your-IP-address

In the following output, you have pinged your local machine using two different ways. In the first, you use the localhost that means 'ping to my computer'.

In the below output, using IP address ping the local computer system.

Using ping specify internet protocol

The ping command is also used to send request IPv4 or IPv6 as follows:

$ ping -6 hostname/IPv6

or

$ ping -4 hostname/IPv4

Change ping packets time interval

The default time interval between the requesting packet is 1 second in the Linux. But, according to your requirements, you can increase or decrease this time interval.

If you want to increase this time interval then you need to set above 1 as follows:

$ ping -i 3 host-name/IP

If you want to decrease the interval then you will set the time less than 1 as follows:

$ ping -i 0.5 linuxhint.com

Change ping packet size

Using the ping command, you can change the size of ping packets. The default size of the packet is set to 56 (84) bytes. The parentheses number represents that on sending ping bytes 28 packet header bytes will also include in the packet size. You can change this size using the following command:

$ ping -s packetsize hostname/IP

The above command is used to test network performance.

For example, we have changed the ping packet size to 150 as follows:

$ ping -s 150 64.9.238.144

Set limit to desire number of ping packets

If you want to set limits that ping request automatically stopped after the specified number of ping packets then you can use the following command:

$ ping -c set-limit host-name/IP

For example, set the ping request to 7 which means after sending 7 ping packets, the ping request will automatically terminate. You can see the output in the following image:

$ ping -c 7 127.0.0.1

Using ping command flood a network

Under the heavy load, you can test your network performance using the ping flood. The ping flood must be executed under the root user. The '-f' is used with ping command as follows:

$ sudo ping -f host-name/IP

Using this command, large packets send to the network for testing performance.

The dots represent the sending packet and it prints backspace for each response.

Set timeout for a ping request

Using the ping command, you can also set a timeout limit for ping requests. It means that after the specified time the ping will stop displaying the results on the terminal. Use the following command to check results:

$ ping -w time-in-seconds host-name/IP

Here, after 6 seconds ping automatically stops to print results.

$ ping -w 6 linuxhint.com

Ping with an audible response

Using the following ping command, you can set a beep play that will check that the host available or not:

$ ping -a host-name/IP

Check ping version

You can check the ping utility version using the following command:

$ ping -V

In this article, we have practiced various ping command on Ubuntu 20.04 Linux system to check the network performance in an optimized way. Furthermore, you can work on advanced switches or tags that are used with ping command to customize the send and response requests.

Top 5 Karten zur Spielaufnahme
Wir alle haben Streaming-Gameplays auf YouTube gesehen und geliebt. PewDiePie, Jakesepticye und Markiplier sind nur einige der Top-Gamer, die Millione...
So entwickeln Sie ein Spiel unter Linux
Vor einem Jahrzehnt hätten nicht viele Linux-Benutzer vorhergesagt, dass ihr Lieblingsbetriebssystem eines Tages eine beliebte Spieleplattform für kom...
Open-Source-Ports kommerzieller Spiele-Engines
Kostenlose, quelloffene und plattformübergreifende Spiel-Engine-Nachbildungen können verwendet werden, um sowohl alte als auch einige der relativ neue...