How to Test Your Internet Speed from the Linux Terminal

Diagnosing network issues on a desktop computer is usually as simple as opening a web browser and navigating to a bandwidth benchmarking website. But what happens when you need to diagnose a slow connection on a headless Linux server that does not have a graphical user interface (GUI) or a web browser installed?

For system administrators managing remote servers via SSH, command-line utilities are the only option. By learning how to test your internet speed from the Linux terminal, you can quickly verify if your server is suffering from an ISP bottleneck or internal network throttling.

Introducing Speedtest-CLI

The easiest and most reliable way to benchmark your bandwidth in the terminal is by using speedtest-cli. This is an open-source, command-line interface for Ookla’s famous Speedtest.net infrastructure.

It connects to the exact same global network of testing servers as the website, ensuring accurate, highly comparable results without requiring a browser.

How to Install Speedtest-CLI

Because the utility is written in Python, it is available in the default package repositories of almost every major Linux distribution.

If you are using a Debian or Ubuntu-based system, open your terminal and run the following command:

sudo apt update && sudo apt install speedtest-cli

If you are using a Red Hat, CentOS, or Fedora-based system, you will use the dnf package manager instead:

sudo dnf install speedtest-cli

The installation will only take a few seconds and requires less than a megabyte of disk space.

Running a Basic Speed Test

Once the software is installed, running a benchmark is incredibly simple. You do not need root privileges to execute the test.

Simply type the following command and press Enter:

speedtest-cli

The utility will automatically ping the Speedtest.net infrastructure, determine your server’s current IP address, and locate the geographically closest testing server to minimise latency.

The output will update in real-time, displaying your:

  • Ping (Latency): Measured in milliseconds (ms). Lower is better.
  • Download Speed: Measured in Megabits per second (Mbit/s).
  • Upload Speed: Measured in Megabits per second (Mbit/s).

Advanced Speedtest Commands

While the basic command is usually sufficient, speedtest-cli offers several excellent flags for more specific use cases.

1. Share Your Results with a URL

If you need to prove to your ISP or a client that the server is underperforming, you can generate a graphical PNG image of your results hosted on Speedtest.net.

speedtest-cli --share

At the very end of the output, the terminal will provide a URL (e.g., Share results: http://www.speedtest.net/result/123456789.png). You can copy and paste this link into a browser or email.

2. Output Results in Bytes (Not Bits)

By default, network speeds are measured in Megabits (Mbit/s). However, file sizes are measured in Megabytes (MB). If you want to know exactly how many Megabytes your server can download per second, use the bytes flag.

speedtest-cli --bytes

3. Generate Minimal Output for Scripts

If you are writing a bash script to monitor your network speed over time, you do not want the ASCII art and formatting text clogging up your log files. Use the simple flag to output just the raw numbers.

speedtest-cli --simple

This will return three clean lines of text:

Ping: 12.34 ms
Download: 945.67 Mbit/s
Upload: 890.12 Mbit/s

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.