Ubuntu 18.04 Ping Tutorial

29/12/2020
Most often when we work with servers and start to SSH them and access them via command-line, we face issues with resolving the domain names to corresponding hostnames. Luckily, manually checking this is not very difficult on Ubuntu via a very easy command-line utility known as Ping. In this lesson, we will explore the capabilities of Ping command on Ubuntu 18.04 LTS machine and see what are the commands we can use with Ping utility for various tasks. Let’s get started.

Getting Started with Ping

Ping is one of the easiest commands to use on Ubuntu. Its syntax is incredibly simple and is described as:

ping domain_name_to_resolve.com

If this utility is able to resolve the domain name passed to it, it will show output as:

PING domain_name_to_resolve.com (192.102.144.29) 56(84) bytes of data.
64 bytes from 192.102.144.29: icmp_req=1 ttl=64 time=0.016 ms
64 bytes from 192.102.144.29: icmp_req=2 ttl=64 time=0.028 ms
64 bytes from 192.102.144.29: icmp_req=3 ttl=64 time=0.021 ms
. . .

This will be regularly output on the terminal window until you break the loop with Ctrl + C combination key. If you want the command to ping only certain number of times, you can tell the utility with an added parameter:

ping -c 3 domain_name_to_resolve.com

This time, we will see the output as:

Ping domain n times

This way, we can use the command to check if the domain name resolves to the IP address that we assigned to it or not.

Ping version

We can check the version which is currently installed on our Ubuntu machine for the Ping command-line utility with the following command:

ping -V

We will see the following output with the above command:

Checking Ping version

Controlling the size of Packet with Ping

When we ping a domain, a default sized packets are sent to the hosting server. If we want to control the size of packets which are sent to the host when we perform a ping operation, we can use the following command:

ping -s 40 -c 5 www.linuxhint.com

This way, we are sending 40-byte packet data 5 times to the specified hostname, the output we will get is:

Data Packet size for Ping

Time Interval for Ping

With Ping utility, the data packets are sent at an interval of one second to the host server. We can update the time gap between the pings with the following command:

ping -i 2 -c 5 www.linuxhint.com

The -i option can accept the second count. We will see a similar output:

Changing time interval for Ping

Making a noise with Ping

Ping can even be modified to make a bell sound whenever a response packet is received back from the host server with the following command:

ping -a www.linuxhint.com

Of course, showing its output is not possible.

Suppressing Output for Ping

Usually, we do not care about what happened when each packet is sent and data is received back as a response with each Ping. In these cases, we can suppress the output by showing information related to first Ping and the final data. This can be done as follows:

ping -q -c 3 linuxhint.com

With this command, ping command will be executed in quiet mode and following output will appear on screen:

Ping Quiet mode

Total Time to Ping

We can even tell Ping command to reach a server and ping it for an only specified amount of time. So, with the following command, we ping the server for only 5 seconds in total:

ping -w 5 linuxhint.com

The following output will appear on screen:

Total interval for Ping

Conclusion

In this lesson, we saw how we can reach out to a server and ping for its availability using one of the most simple command-line utility available on an Ubuntu machine. Read more Ubuntu lessons here.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Install DEB Packages on Ubuntu

The package files of Ubuntu have the extension .deb and it’s also called DEB files. On Ubuntu, there are many ways to...
29/12/2020

How to install CopyQ 3.0.3 on Ubuntu 17.04 & Below

CopyQ 3.0.3 recently released, is a monitoring app that allows you to monitor system clipboard and saves its content in...
28/12/2020

Install Anaconda Python on Ubuntu

Anaconda is a distribution of the Python programming language, which is used by data scientists all over the world. Anaconda...
12/02/2020
Bài Viết

Bài Viết Mới Cập Nhật

Huớng dẫn dùng proxy cho ios, iphone 2023
23/09/2023

Cách gắn set proxy cho điện thoại android, oppo, giả lập android, Ldplayer Bằng Proxydroid
20/09/2023

Mua Proxy Socks5 VN Chơi Game Gia Lập Tăng Cường Trải Nghiệm Chơi Game
22/06/2023

Mua Proxy Mỹ, Us Nuôi Tài Khoản Etsy, eBay Tìm Hiểu Về Mua Proxy Mỹ tại Onet.com.vn
22/06/2023

Mua Proxy Game – Giải pháp tuyệt vời cho việc chơi game trên mạng mà không bị giới hạn về vị trí địa lý
03/06/2023