Have you ever wanted to make a speedtest from your terminal, and not from these heavy websites stuffed with ads?

Have you ever wanted to make a speedtest from your terminal, and not from these heavy websites stuffed with ads? How about from a headless machine like a server?

Tip

Update: there is now an official and more reliable CLI.

Well you can, with speedtest-cli, a open source python script that uses the speedtest.net API.

It’s lightweight and easy to install: you just have to install Python 2.x or 3.x on your machine and download the .py file, or install it via PIP (Python Package Index):

pip install speedtest-cli

See Installation for more details.

Then, you can launch a speedtest using the speedtest or speedtest-cli command:

user@server ~# speedtest-cli
Retrieving speedtest.net configuration...
Testing from Free SAS (123.123.123.123)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by CAPACOM by Net1C (Paris) [1.88 km]: 2.494 ms
Testing download speed................................................................................
Download: 838.01 Mbit/s
Testing upload speed................................................................................
Upload: 775.97 Mbit/s

You can generate a image with your results:

user@server ~# speedtest-cli --share
Retrieving speedtest.net configuration...
Testing from Free SAS (123.123.123.123)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by CAPACOM by Net1C (Paris) [1.88 km]: 2.494 ms
Testing download speed................................................................................
Download: 838.01 Mbit/s
Testing upload speed................................................................................
Upload: 775.97 Mbit/s
Share results: http://www.speedtest.net/result/7021364543.png
speedtest-cli

Or specify a speedtest server:

user@server ~# speedtest-cli --server 1066
Retrieving speedtest.net configuration...
Testing from Free SAS (123.123.123.123)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Tele Greenland A/S (Nuuk) [3582.52 km]: 155.541 ms
Testing download speed................................................................................
Download: 106.35 Mbit/s
Testing upload speed................................................................................
Upload: 191.97 Mbit/s

You can find the list here. And there are even more options available!

Disclaimer though, speedtest-cli is not a reliable tool, and can give you different results depending on the server, the python version, the speedtest server, etc. However, it’s still a good tool to get an idea of a server’s connection, or to do a quick speedtest on your PC.