You can use the Linux command ping to check whether you’re connected to other computers or devices in your network. It works with most operating systems and internet-enabled devices.

What is the Linux ping command?

The ping command is an easy and proven tool to check whether a computer or device is available in your current network. You send a request using the command which should be answered quickly. You can then assume that there is a con­nec­tion between the two devices and is available to be used. The requests and answers aren’t just limited to Linux and on Linux dis­tri­bu­tions such as Ubuntu, rather all common operating systems. Most devices, including routers, printers and scanners can also respond to a ping request. Although it is possible to manually disable the automatic response to a ping request, this does not provide any security benefits.

How does the Linux ping command work?

The ping command is entered and executed in the terminal. It sends a simple signal to a set des­tin­a­tion which will answer with its own signal. The des­tin­a­tion is set by using an IP address or a host name. In the second case, an attempt is made to resolve the hostname into a DNS address, which is why the ping command is also suitable for finding out addresses like these. If Linux ping isn’t stopped manually or by using an option, it will send a signal every second forever. There are two different versions of the command: ‘ping’ is used for IPv4 addresses and ‘ping6’ for IPv6 addresses.

What does the ping syntax look like?

The ping command has the following syntax:

$ ping [Options] [Target]
shell

ping is the actual command which can be adjusted using the options. The target can either be a set IP address or a host name.

What options does the ping command have?

There are many options alongside the ping command. These are the most important:

  • -c [Count]: With this option you can set how many requests are sent in total. Once this amount has been reached the ping command stops.
  • -I [Interface]: This option sets via which in­ter­faces the ping request is sent.
  • -i [Interval]: This option allows you to set the intervals between the requests. This is normally a second and the interval is also set in seconds.
  • -W [Wait]: This option allows you to set how long the command should wait for an answer until it auto­mat­ic­ally stops trying. This is also given in seconds.
  • -w [End time]: You can use this option to set how long a ping request should be carried out for. Once the time has elapsed, again given in seconds, contact is ended re­gard­less of whether it was suc­cess­ful or not.

Examples of a ping command

To make it easier to see how the Linux ping command works, here are some simple examples:

$ ping examplesite.com
shell

This command will ping the website ex­amples­ite.com every second without stopping. The result will display the DNS address of the website.

$ ping -c 5 examplesite.com
shell

This command sends five pings to ex­amples­ite.com and will tell you if they were suc­cess­ful or not. After five attempts contact will be stopped.

$ ping6 ipv6.examplesite.com
shell

With this option you can see if an IPv6 internet con­nec­tion is available and whether the page ex­amples­ite.com can be reached from it.

Go to Main Menu