How to run a speed test from command line using speedtest-cli Print

  • speedtest, cli
  • 2

Installing speedtest-cli

There are fundamentally three ways of installing the speedtest-cli application. Since the program is present in the default repositories of all the major linux distributions, the first and preferred installation method is the one which involves the use of our favorite package manager. For example, to install the application on Fedora we use dnf:

$ sudo dnf install speedtest-cli

On Debian or Debian-based distributions we can use the good old apt:

$ sudo apt-get update && sudo apt-get install speedtest-cli

Speedtest-cli is also present in the Archlinux's Community repository, therefore we can install it via pacman:

$ sudo pacman -S speedtest-cli

Since speedtest-cli is written in python, is also possible to install it in a distro-independent way, by using pip (or pip3), the python package manager. When installing the package this way, I recommend the use of the --user flag to perform the action only for our user:

$ pip3 install speedtest-cli --user


Finally, we can install speedtest-cli by cloning the github repository:

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

Once the repository is cloned we can switch inside of it and issue the following command:

$ python3 setup.py install --user

How to use speedtest-cli

The easiest way of using speedtest-cli, is just by invoking it without options in the terminal. First the application will select the closest available server to test the connection against, then it will display the download and upload speed:

Checking Internet connection speed results from the Linux terminal
Checking Internet connection speed results from the Linux terminal

As you can see, by default the speed is expressed in bits. To use bytes, instead, we can use the --bytes option.

We saw the basic usage of the command, now let's see how we can customize its behavior with the possible options.



Sharing the results with the --share option

One very useful option of speedtest-cli is --share: when using it, a graphical representation of the results of the speed test will be generated and hosted online; the command will return the URL we can use to access and share it:

Sharing Internet speed results
Sharing Internet speed results

Using the csv or json formats for the results

Speedtest-cli can generate the results in csv format by using the --csv option. In this case the verbose output its suppressed and the results are generated on a single line using a , (comma), as the default field delimiter. This can be changed by using the --csv-header option. For example, to use the | character as the delimiter, we can run:

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

The csv headers can be printed by using --csv-header option:


$ speedtest-cli --csv-header
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload

The results can also be represented by using the json format. The --json option can be used to obtain this behavior.


Source: https://linuxconfig.org/how-to-run-a-speed-test-from-command-line-using-speedtest-cli


Was this answer helpful?

« Back