Speedtest is a great tool to verify the status of your internet connection. With it you could check if your ISP (Internet Service Provider) is providing you the speed you have contracted. Normally you would like to use the Speedtest Website version, but here I am going to explain how to use from a Linux Command Line or Linux Terminal. This tutorial is based of the use of the speedtest-cli GitHub Project.

Installation

Installation with apt

In Debian like version (such us Ubuntu), we can install it from the offical repositories using apt.

sudo apt install speedtest-cli

Installation with pip

pip is a package-management system written in Python.

pip install speedtest-cli

Installation using GitHub

git clone https://github.com/sivel/speedtest-cli.git

Inside speedtest-cli directory, you could find the speedtest.py executable.

Installation using cURL

If you don’t want any installation, this option will only download the Python script.

curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

Installation using Wget

The same as cURL, but with Wget.

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

How to use it

Default mode

The default way to use speedtest-cli is without any arguments. The application will select the nearest server to perform the test. It will show the Download and Upload speed.

Retrieving speedtest.net configuration...
Testing from Orange Espana (X.X.X.X)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Orange (Madrid) [18.00 km]: 16.887 ms
Testing download speed................................................................................
Download: 599.38 Mbit/s
Testing upload speed......................................................................................................
Upload: 591.20 Mbit/s
yvoictra|saturn:~$

In my case the connection I have is 600/600 Mbps, and the Speedtest result shows a good performance of my connection.

Selecting a server

If you want to select the server, first you should list the servers available:

speedtest --list

And then use the server ID in the command:

speedtest --server 32556

Getting the result in CSV format

It could be interesting to have a CSV file with several results in order to analyze them. If you want to get the result in CSV format, you have to add the --csv-delimiter and also you could choose the delimiter character as an option:

speedtest-cli --csv --csv-delimiter '|'

You could also get the header values:

speedtest-cli --csv-header --csv-delimiter '|'

Sharing the result

There is a way to share the results with a link to a PNG image. To get this link you have to add --share option.

speedtest-cli --share

With the result you’ll get a link to a PNG image as the one before.

Conclusion

As you can see the application speedest-cli offers the same information as you have from the Speedtest Website, but it can be executed from a Linux Terminal. This could be an advantage if you want to execute the test remotely or if you want to program tests, using scripts or similar.