When troubleshooting a sluggish internet connection or configuring a remote server, opening a web browser to run a speed test isn’t always an option. For headless Linux servers, remote SSH sessions, or users who simply prefer the efficiency of the command line, speedtest-cli is an indispensable utility.
Here is a comprehensive breakdown of how to install, use, and get the most out of this lightweight tool.
Key Features
- Bi-directional Testing: Measures both download and upload bandwidth.
- Latency Verification: Calculates ping and jitter to assess connection quality.
- Server Selection: Allows targeting of specific global testing nodes.
- Shareable Results: Generates URLs to easily share visual performance graphics.
- Automation-Friendly: Formats data for scripts and logging systems.
Installation
Because speedtest-cli is written in Python, it can be installed easily across various operating systems using standard package managers.
On Ubuntu / Debian
bash
sudo apt update && sudo apt install speedtest-cli
Use code with caution.
On Fedora / CentOS / RHEL
bash
sudo dnf install speedtest-cli
Use code with caution.
via Python Package Index (Pip)
bash
pip install speedtest-cli
Use code with caution.
Essential Commands
The simplest way to use the tool is by running it with no arguments. This automatically finds the closest testing server based on ping and runs a standard test:
bash
speedtest-cli
Use code with caution.
Advanced Usage Examples
- Share Results: Append the share flag to receive a URL link to a PNG image hosted on Speedtest.net.bash
speedtest-cli --shareUse code with caution. - List Nearby Servers: View a sorted list of nearby testing facilities along with their unique ID numbers.bash
speedtest-cli --listUse code with caution. - Target a Specific Server: Force the tool to test against a precise location using its server ID.bash
speedtest-cli --server [SERVER_ID]Use code with caution. - Simplify the Output: Suppress unnecessary progress text to see only the final results.bash
speedtest-cli --simpleUse code with caution.
Programmatic Data Output
For developers building monitoring tools or sysadmins logging network health over time, raw text can be difficult to parse. speedtest-cli handles this natively by exporting data into structured formats.
To grab results formatted cleanly for databases, CSV logging, or API consumption, use the following commands:
- CSV Format:
speedtest-cli --csv - JSON Format:
speedtest-cli --json
Integrating these flags into a cron job makes it remarkably straightforward to build a historical log of network reliability and ISP performance trends.