LinuxCommandLibrary

speedtest-cli

Test internet connection speed

TLDR

Run a speed test

$ speedtest-cli
copy

Run a speed test and display values in bytes, instead of bits
$ speedtest-cli --bytes
copy

Run a speed test using HTTPS, instead of HTTP
$ speedtest-cli --secure
copy

Run a speed test without performing download tests
$ speedtest-cli --no-download
copy

Run a speed test and generate an image of the results
$ speedtest-cli --share
copy

List all speedtest.net servers, sorted by distance
$ speedtest-cli --list
copy

Run a speed test to a specific speedtest.net server
$ speedtest-cli --server [server_id]
copy

Run a speed test and display the results as JSON (suppresses progress information)
$ speedtest-cli --json
copy

SYNOPSIS

speedtest-cli [options]
speedtest-cli --list
speedtest-cli --server SERVER_ID

PARAMETERS

--list
    List all available Speedtest.net servers sorted by distance.

--server SERVER_ID
    Specify a particular server ID to test against. Use --list to find server IDs.

--share
    Generate and provide a URL to the official Speedtest.net share results image.

--simple
    Suppress verbose output and display only basic download, upload, and ping information.

--json
    Output results in JSON format, suitable for scripting and parsing.

--csv
    Output results in CSV format, useful for spreadsheet applications or data analysis.

--bytes
    Display speeds in Bytes/second instead of the default Bits/second.

--no-pre-allocate
    Disable pre-allocation of upload test data. Can be useful on systems with limited memory.

--secure
    Use HTTPS instead of HTTP for communication with Speedtest.net servers.

--source IP_ADDRESS
    Bind to a specific IP address when making network connections.

--timeout SECONDS
    Set a timeout for connection attempts (default is 10 seconds).

--version
    Show the program's version number and exit.

--help
    Display the help message and exit.

DESCRIPTION

speedtest-cli is a powerful command-line interface for testing internet bandwidth using Speedtest.net. It enables users to conveniently measure their internet connection's download speed, upload speed, and latency (ping) directly from the terminal, eliminating the need for a web browser. This tool is exceptionally valuable for server administrators, network engineers, and anyone requiring quick network performance checks on headless systems or for automation scripts.

It intelligently automates the process of identifying the optimal nearest Speedtest server, executing the tests, and presenting the results. The output can be formatted in various user-friendly ways, including standard human-readable text, JSON, CSV, or even generate a shareable image link of the results. This versatility makes speedtest-cli ideal for integration into scripts, monitoring systems, or for simple, on-demand performance assessments.

CAVEATS

Results from speedtest-cli might slightly vary from browser-based Speedtest.net tests due to differences in testing methodologies, network conditions, or server selection. The accuracy is highly dependent on the chosen server's proximity and current load; using --list and --server can help optimize this. Note that speedtest-cli is a third-party client and not officially supported by Speedtest.net (Ookla), meaning its functionality is dependent on the stability of the public Speedtest.net API and could be affected by changes.

INSTALLATION

speedtest-cli can typically be installed using Python's pip package installer (pip install speedtest-cli) or through distribution-specific package managers (e.g., sudo apt install speedtest-cli on Debian/Ubuntu, sudo dnf install speedtest-cli on Fedora/RHEL).

SERVER SELECTION STRATEGY

By default, speedtest-cli intelligently identifies the nearest and fastest server based on ping response times. However, users have the flexibility to manually specify a desired server ID using the --server option, which is particularly useful for testing against specific geographical locations or known high-performance servers.

HISTORY

speedtest-cli was initiated by Matt Martz in 2013, driven by the need for a simple, scriptable method to test internet speeds directly from the command line, bypassing the traditional web browser requirement. Its introduction filled a significant gap for system administrators and automation tasks on headless servers. The project quickly gained widespread adoption in the Linux and system administration communities due to its straightforward usage and adaptability. As an open-source project, it has benefited from continuous community development, enhancing its accuracy, adding features like JSON/CSV output, and ensuring ongoing compatibility with the evolving Speedtest.net infrastructure. Its core focus has consistently been on providing a lightweight and reliable alternative to web-based speed tests.

SEE ALSO

ping(8), traceroute(8), iperf3(1), netstat(8)

Copied to clipboard