Introduction

The ping command is one of the most common and useful tools in networking. It is used to test connectivity, measure latency, and detect packet loss between one device and another. Its operation is based on the Internet Control Message Protocol (ICMP), which works at the network layer of the OSI model.

When a user runs the command, the computer sends an ICMP Echo Request packet to the target host. This packet contains a timestamp and a sequence number. If the target device is reachable, it responds with an ICMP Echo Reply packet. By comparing the time the request was sent and the time the reply was received, the program calculates the round-trip time, also known as latency. During this process, ping shows detailed information such as the size of the packet, the sequence number, the time-to-live value which indicates the number of remaining hops, and the measured response time. Once the execution ends, the command summarizes the results by reporting how many packets were sent and received, the percentage of packet loss, and the average latency.

The operating system’s networking stack plays an important role in this process. The ICMP request is passed to the IP layer of the kernel, where it is encapsulated in an IP packet and sent across the network. When a reply arrives, the kernel delivers it back to the ping process in user space. The program then interprets the reply, calculates statistics such as average round-trip time and packet loss, and displays the results in a human-readable format.

Why Is Ping Command Missing?

Several reasons could cause the ping command to be unavailable in Ubuntu:

  1. Minimal Installation – If you installed Ubuntu using the “Minimal installation” option, essential network tools like ping may not be included by default.
  2. Corrupt or Incomplete Installation – System upgrades or package removals might have accidentally uninstalled ping.
  3. Permissions Issues – In some cases, improper permissions might restrict access to certain system utilities.

How to Install Ping in Ubuntu

The ping command is provided by the iputils-ping package in Ubuntu. To install it, follow the steps below.

Step 1: Update Your Package List

Before installing any software, it’s always a good idea to update your system’s package list to ensure you get the latest version of available packages:

sudo apt update

Step 2: Install iputils-ping

Now, install the package that includes the ping command:

sudo apt install iputils-ping -y 
  • sudo: Runs the command with administrator (root) privileges.
  • apt install: Uses the APT package manager (on Debian/Ubuntu-based systems) to install software.
  • iputils-ping: The specific package being installed. It provides the ping utility, which is used to test network connectivity by sending ICMP echo requests to a host.
  • -y: Automatically answers “yes” to all prompts during installation, so the process runs without asking for confirmation.

This command downloads and installs iputils-ping along with any dependencies.

Step 3: Verify the Installation

After installation, verify that ping is now available by running:

ping -V
If all packages have been successfully installed, the following should be displayed:

Alternative Methods to Install Ping

If the default method does not work, here are some alternative approaches:

1. Install Using Snap (If Applicable)

Some minimal Ubuntu distributions do not include apt by default. If Snap is installed on your system, you can install ping using:

sudo snap install iputils

2. Use BusyBox

BusyBox is a lightweight alternative that includes various Unix utilities, including ping. Install it using:

sudo apt install busybox

Then, run:

busybox ping google.com

This will confirm that ping is available via BusyBox.

Common Errors and Fixes

1. “Ping: Permission Denied”

If you receive a permission error, it may be due to security restrictions. Try running:

sudo chmod u+s /bin/ping

This sets the correct permissions to allow non-root users to use ping.

2. “Package Not Found”

If Ubuntu cannot find the iputils-ping package, ensure your repository sources are updated:

sudo apt update && sudo apt upgrade

If the issue persists, check your sources list in /etc/apt/sources.list.

When to use the Ping command

1. Check Internet Connectivity

ping google.com
  • Reason: To see if your computer can reach Google’s servers.
  • If you get replies, you know your internet connection is working.

2. Test Connection to a Local Device

ping 192.168.1.1
  • Reason: To verify whether your router or gateway is reachable in your local network.
  • Useful for troubleshooting Wi-Fi or LAN issues.

3. Measure Latency (Response Time)

ping avahost.com
  • Reason: To check how long it takes for data packets to travel to the host and back.
  • Low latency = faster connection (important for gaming, video calls, etc.).

4. Detect Packet Loss

ping -c 5 avahost.com
  • Reason: Sends 20 requests and shows statistics about lost packets.
  • If you see packet loss, it indicates a bad or unstable connection.