How to Test Internet Connection Speed in Ubuntu Terminal Using speedtest-cli

Benchmarking network throughput is an essential troubleshooting task when diagnosing slow web browsing, evaluating server hosting performance, or verifying that your internet service provider (ISP) delivers your contracted bandwidth. While desktop users can easily visit web-based speed test tools, headless servers and terminal-centric Ubuntu workstations require a lightweight, command-line utility. The open-source speedtest-cli utility provides an interactive, scriptable way to measure latency, download bitrate, and upload bandwidth directly inside your shell session.

Installing speedtest-cli on Ubuntu

The speedtest-cli package is maintained in the official Ubuntu Universe repository and can be installed via apt:

  1. Open your terminal by pressing Ctrl + Alt + T or connecting over SSH.
  2. Update your local package index to ensure access to the latest repositories:
    sudo apt update
  3. Install the speedtest command-line package:
    sudo apt install speedtest-cli -y
  4. Confirm the installation and inspect the installed version:
    speedtest-cli --version

Running a Standard Network Benchmark

Executing the command with no arguments automatically contacts Speedtest.net servers, detects your public IP address, calculates latency to the closest geographical server, and runs both download and upload tests:

speedtest-cli

The terminal will output live progress indicators followed by a structured summary:

Retrieving speedtest.net configuration...
Testing from Vodafone UK (198.51.100.42)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Exponential-e (London) [12.45 km]: 14.218 ms
Testing download speed................................................................................
Download: 348.52 Mbit/s
Testing upload speed......................................................................................................
Upload: 72.19 Mbit/s

Running Minimalist and Automated Tests

When running benchmarks within automated maintenance cron jobs or scripts, detailed progress text can clutter output logs. You can streamline test results using command flags:

  • Summary Only (--simple): Omits server list discovery text and prints solely Ping, Download, and Upload metrics:
    speedtest-cli --simple
  • Bytes Instead of Bits (--bytes): Outputs data transfer speeds in megabytes per second (MB/s) rather than megabits per second (Mbit/s):
    speedtest-cli --bytes
  • Shareable Web Result (--share): Generates a PNG result card hosted on Speedtest.net, providing a direct URL to share diagnostic evidence with network administrators or customer support:
    speedtest-cli --share
  • Selecting a Specific Test Server: To benchmark connectivity against a remote data centre rather than your nearest local exchange, list nearby server IDs with speedtest-cli --list and target a specific ID using --server [SERVER_ID].

Get the best tech tips delivered straight to your inbox.

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