Raspberry Pi

How to measure internet speed using speedtest-cli on Raspberry Pi 4

Nowadays, from the social life of man to the business life, everything is connected with the internet, because of which the speed of the internet has a great significance. To check the speed of the internet, we usually browse an internet speed test on the browser and connect to any server to find out the speed of our internet. We can complete this task of finding the speed of the internet without a browser by using a simple tool of the speedtest-cli on the Raspberry Pi operating system.

The speedtest-cli is an application that is used to find the speed of the internet through the command line and in this guide, we will explore the methods to install and use the speedtest-cli. We will install the speedtest-cli on RaspberryPi using the methods:

  • By downloading the speedtest-cli package from its website
  • Through the pip
  • Through the Python script

Method 1: How to install the speedtest-cli by downloading its package from its website

The speedtest-cli is not usually come in the default repository of the Raspberry Pi operating system, so we will install its deb package from its official website using a command:

$ curl -s https://install.speedtest.net/app/cli/install.deb.sh

In the above command, the “s” flag is used to specify the certificate file, once the package has been downloaded, we will install it using the command:

$ sudo apt install speedtest -y

Now, if we want to delete the package, we can use the purge command:

$ sudo apt purge speedtest -y

Method 2: How to install the speedtest-cli through the pip

We can also install the speedtest-cli application through the pip, but as we know the speedtest-cli is dependent on the python language, so first we will install the python packages using the command:

$ sudo apt install python3-venv python3-pip -y

After the successful installation of the python packages, we will install speedtest-cli using the pip3:

$ sudo pip3 install speedtest-cli

To uninstall the speedtest-cli using the pip3, we will use the command:

$ sudo pip3 uninstall speedtest-cli -y

Method 3: How to install the speedtest-cli through Python script

The other way to install the speedtest-cli on Raspberry Pi is by using the Python script of the speedtest.py, for this we will download its script from the githubusercontent.com using the wget command:

$ wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py

Now, we will change the permissions of speedtest-cli:

$ chmod +x speedtest-cli

We will move the downloaded package of the speedtest-cli to the “/usr/bin/” directory using the command:

$ sudo mv speedtest-cli /usr/bin/

We have moved the speedtest-cli to the “/usr/bin/” so that when we use the application to measure the speed of the internet, we are not supposed to direct its path.

How to measure the speed of the internet using speedtest-cli on Raspberry Pi

To measure the speed of the internet, launch the application of speedtest-cli using the command:

$ speedtest-cli

In the above output, you can see the results in which the internet speed is shown of download as well as upload, similarly, if you want to display the output in bytes instead of bits unit, use the command:

$ speedtest-cli --bytes

To share these results with anyone else, use the command:

$ speedtest-cli --share

A link is displayed where the results of your internet has been shown, you can share this link to anyone with whom you want to share the results, if you open the URL, a image will be displayed as:

Conclusion

The internet speed can be measured using the application of the speedtest-cli on Raspberry Pi and this application is useful as it can measure the speed of the internet and we can also share the results of speedtest-cli by simply sharing the URL with other users. In this write-up, we have discussed different methods of installation of the speedtest-cli on Raspberry Pi and also discuss how to use it for measuring the internet speed.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.