LinuxCommandLibrary

speedtest

Test internet connection speed

TLDR

Run a speed test

$ speedtest
copy

Run a speed test and specify the unit of the output
$ speedtest --unit=[auto-decimal-bits|auto-decimal-bytes|auto-binary-bits|auto-binary-bytes]
copy

Run a speed test and specify the output format
$ speedtest --format=[human-readable|csv|tsv|json|jsonl|json-pretty]
copy

Run a speed test and specify the number of decimal points to use (0 to 8, defaults to 2)
$ speedtest --precision=[precision]
copy

Run a speed test and print its progress (only available for output format human-readable and json)
$ speedtest --progress=[yes|no]
copy

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

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

SYNOPSIS

speedtest [options]

PARAMETERS

--help
    Show help message and exit.

--version
    Show the version number and exit.

--list
    Display a list of Speedtest.net servers sorted by distance.

--server SERVER
    Specify a server ID to test against.

--source ADDRESS
    Source address used for outbound connections.

--timeout TIMEOUT
    HTTP timeout in seconds. Default: 10.

--bytes
    Display values in bytes instead of bits. Does not affect the image output.

--no-upload
    Do not perform upload test.

--no-download
    Do not perform download test. Useful for determining latency

--single
    Only use a single connection simultaneously. useful for smaller servers.

--csv
    Output CSV format. Delimiter: ',' . Values surrounded by double quotes.

--json
    Output JSON format.

--share
    Generate and provide a Speedtest.net share results URL.

--secure
    Use HTTPS instead of HTTP when communicating with Speedtest.net servers.

--no-pre-allocate
    Disable pre-allocation. Pre-allocates a larger initial buffer.

DESCRIPTION

The `speedtest` command, typically provided by speedtest-cli, allows users to measure the internet connection's download and upload speeds, as well as latency (ping) from the Linux command line. It interacts with Speedtest.net servers to perform these tests. It eliminates the need to open a web browser and navigate to the Speedtest.net website, providing a convenient and efficient way to assess network performance directly from the terminal. The script automatically selects the best Speedtest.net server based on ping. It outputs results in various formats, including text, CSV, and JSON, allowing for easy integration with other tools and scripts. The `speedtest` command is particularly useful for troubleshooting network issues, monitoring network performance over time, or simply verifying the advertised speeds of an internet service provider. The results include the ping time to the server, the download speed, the upload speed, and the server location. It can be scripted and automated, making it ideal for continuous network monitoring. You must install `speedtest-cli` separately from the package manager, as it doesn't come preinstalled.

CAVEATS

The accuracy of the results depends on the network conditions, the server selected, and the overall load on the Speedtest.net infrastructure. Network traffic during the test can significantly impact results. The `speedtest-cli` package is not part of the base Linux distribution and must be installed separately. Some distributions may require different package names (e.g., `speedtest-cli`, `python3-speedtest-cli`). Requires Python.

OUTPUT FORMATTING

The `--csv` option provides a comma-separated values output, which is useful for importing data into spreadsheets or databases. The `--json` option provides a JSON output which can be parsed by other applications.

TROUBLESHOOTING

If the command fails, ensure that Python is installed and the `speedtest-cli` script is executable. Verify internet connectivity using `ping` before running `speedtest`. Firewall or proxy settings may also interfere with the test. Check the Speedtest.net server status if experiencing consistently inaccurate results.

HISTORY

The `speedtest-cli` command is a Python script developed by Matt Martz. It provides a command-line interface for performing internet speed tests using Speedtest.net's servers. The initial development focused on providing a lightweight and easily scriptable alternative to the web-based Speedtest.net interface. It quickly gained popularity among network administrators and developers for its ease of use and automation capabilities. Over time, the script has been updated to support various features, including different output formats, server selection, and secure connections. It is maintained by the open source community.

SEE ALSO

ping(8), traceroute(8), curl(1)

Copied to clipboard