If you need to test your connection speed without opening a browser or for example from a headless server. You can check your speed from the Linux command line with speedtest-cli.
Speedtest-cli is a network testing tool written in python and compatible for versions 2.4 to 3.7 and still be actively updated. it’s easily installed through pip and features a variety of options to employ.
How to Install
First, make sure pip the python package manager is installed by opening a terminal and entering:
sudo apt install python3-pip
Next install speedtest-cli with:
pip3 install speedtest-cli
You can run the package by then entering:
The program will automatically find the best server based on ping tests and begin downloading and then uploading packets to calculate your download and upload speeds.
Note: The tool is not designed to be 100% accurate as factors such as the way speedtest.net calculates speed and configuration of your machine can affect the performance. It is however perfect for general usage and diagnostics.
-h, --help show this help message and exit --no-download Do not perform download test --no-upload Do not perform upload test --single Only use a single connection instead of multiple. This simulates a typical file transfer. --bytes Display values in bytes instead of bits. Does not affect the image generated by --share, nor output from --json or --csv --share Generate and provide a URL to the speedtest.net share results image, not displayed with --csv --simple Suppress verbose output, only show basic information --csv Suppress verbose output, only show basic information in CSV format. Speeds listed in bit/s and not affected by --bytes --csv-delimiter CSV_DELIMITER Single character delimiter to use in CSV output. Default "," --csv-header Print CSV headers --json Suppress verbose output, only show basic information in JSON format. Speeds listed in bit/s and not affected by --bytes --list Display a list of speedtest.net servers sorted by distance --server SERVER Specify a server ID to test against. Can be supplied multiple times --exclude EXCLUDE Exclude a server from selection. Can be supplied multiple times --mini MINI URL of the Speedtest Mini server --source SOURCE Source IP address to bind to --timeout TIMEOUT HTTP timeout in seconds. Default 10 --secure Use HTTPS instead of HTTP when communicating with speedtest.net operated servers --no-pre-allocate Do not pre allocate upload data. Pre allocation is enabled by default to improve upload performance. To support systems with insufficient memory, use this option to avoid a MemoryError --version Show the version number and exit
Using the –share option provides a URL to a rather nifty graphic perfect for integrating into a project to show connection speeds.
It’s also possible to test the connection over HTTPS as opposed to HTTP by appending –secure.
Overall speedtest-cli is a handy tool to measure network speeds and can be easily integrated into scripts and other projects. You can find more information over at the github project page
How do you measure your Internet speed? Let us know in the comments below.