Speedtest CLI on Ubuntu [How To Install]


In this tutorial, we learn how to install and use Speedtest CLI on Ubuntu. Running speedtest CLI can be beneficial in the hosting environment to check whether the provided bandwidth is as advertised.

Speedtest CLI can also be used to check our own internet connection. Running from command line should provide better test compared to browser based test since command line will have cleaner test environment, for example no browser plugins.

We will install the official speedtest command line application provided by ookla.

Add Speedtest CLI repository

curl -s http<span class="hljs-variable">s:</span>//<span class="hljs-keyword">deb</span>.<span class="hljs-keyword">sh</span> | sudo bash

The output for the command above will be similar to output below.

Detected operating <span class="hljs-keyword">system</span> as Ubuntu/focal.
<span class="hljs-function"><span class="hljs-title">Checking</span></span> <span class="hljs-keyword">for</span> curl...
<span class="hljs-function"><span class="hljs-title">Detected</span></span> curl...
<span class="hljs-function"><span class="hljs-title">Checking</span></span> <span class="hljs-keyword">for</span> gpg...
<span class="hljs-function"><span class="hljs-title">Detected</span></span> gpg...
<span class="hljs-function"><span class="hljs-title">Running</span></span> apt-get update... done.
<span class="hljs-function"><span class="hljs-title">Installing</span></span> apt-transport-https... done.
Installing /etc/apt/sources.list.d/ookla_speedtest-cli.list...done.
<span class="hljs-function"><span class="hljs-title">Importing</span></span> packagecloud gpg key... done.
<span class="hljs-function"><span class="hljs-title">Running</span></span> apt-get update... done.

The repository is setup! You can now install packages.

The script will do the following operations for us:

  • Detect operating systems version.
  • Check for the availability of certain tools (curl and gpg).
  • Install apt-transport-https package to enable apt download packages from package repository using https.
  • Create new repository configuration in /etc/apt/sources.list.d/ookla_speedtest-cli.list
  • Import packagecloud gpg key. This key will be used by apt to verify that the package being downloaded is the correct package created and signed by packagecloud.
  • Running apt-get update command to refresh apt package index.

Install Speedtest CLI on Ubuntu

Now the repository configuration is ready, we can install speedtest CLI on Ubuntu using the following command.

sudo apt-<span class="hljs-keyword">get</span> install speedtest

Run Speedtest CLI

We can run speedtest without using any options or parameters

<span class="hljs-attribute">speedtest</span>

Speedtest CLI will choose the closest speedtest server and start. On the first run, we have to accept EULA, terms and privacy policy.

speedtest cli ubuntu

List Speedtest Command Options

To list speedtest CLI options we can use the --help option.

speedtest --help
```<figure class="wp-block-image size-large is-style-default">

<img loading="lazy" width="750" height="400" src="" alt="" class="wp-image-2721" /> </figure> 

## Listing Speedtest Servers {#listing-speedtest-servers}

To get list of closest speedtest servers we can use `-L` options

&lt;span class="hljs-attribute"&gt;speedtest -L&lt;/span&gt;
```<figure class="wp-block-image size-large is-style-default">

<img loading="lazy" width="750" height="400" src="" alt="speedtest cli Ubuntu - listing speedtest servers" class="wp-image-2722" /> </figure> 

## Run Speedtest From Specific Server {#run-speedtest-from-specific-server}

From the output of the command above where we get a list of closest speedtest servers, copy the ID of the server that we want to use.

We can run the following command to run speedtest from spesific server.

speedtest -s &lt;span class="hljs-tag"&gt;&lt;&lt;span class="hljs-name"&gt;server_id&lt;/span&gt;&gt;&lt;/span&gt;
```<figure class="wp-block-image is-style-default">

<img loading="lazy" width="750" height="337" src="" alt="" class="wp-image-2723" /> </figure> 

## Video Tutorial {#video-tutorial}

## Summary {#summary}

In this tutorial, we learn how to install and run Speedtest CLI on Ubuntu. We also learn how to get a list of the closest Speedtest servers and run speedtest from a specific server.