Cyberithub

How to Install and Use Speedtest CLI to Test Internet Speed on Linux

Advertisements

In this article, we will see the steps to install and use Speedtest CLI to test Internet Speed on Linux. Speedtest CLI is a free and open source utility available for Software Developers, system administrators and Computer Enthusiasts to test the Internet Bandwidth on Linux Based Systems. With Speedtest CLI, you can easily:-

  • Measure internet connection performance metrics like download, upload, latency and packet loss natively without relying on a web browser.
  • Test the internet connection of your Linux desktop, a remote server or even lower-powered devices such as the Raspberry Pi with the Speedtest Server Network.
  • Set up automated scripts to collect connection performance data, including trends over time.
  • Use Speedtest in your programs by wrapping it in the programming language of your choice.
  • View test results via CSV, JSONL or JSON. More on Speedtest CLI Official page.

How to Install and Use Speedtest CLI to Test Internet Speed on Linux

Install and Use Speedtest CLI to Test Internet Speed on Linux

Also Read: Step by Step Guide to Install Rocky Linux 8.4

Step 1: Prerequisites

a) You should have a running Linux Server.

b) You should have apt-get or yum utility installed in your Server

c) You should have sudo or root access to run privileged commands in your Server.

Step 2: Update Your Server

If you are using CentOS/RHEL based servers then you need to use yum update command to update all the installed packages from enabled Repo.

[root@localhost ~]# yum update 
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 8.8 MB 00:00:02
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.18.4-3.el7 will be updated
---> Package NetworkManager.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-libnm.x86_64 1:1.18.4-3.el7 will be updated
---> Package NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-team.x86_64 1:1.18.4-3.el7 will be updated
---> Package NetworkManager-team.x86_64 1:1.18.8-2.el7_9 will be an update
---> Package NetworkManager-tui.x86_64 1:1.18.4-3.el7 will be updated
---> Package NetworkManager-tui.x86_64 1:1.18.8-2.el7_9 will be an update

If you are using Ubuntu/Debian based system then you need to use apt-get update command to update your System.

[root@localhost ~]# apt-get update

 

Step 3: Install Python-pip Utility

You will need Python pip package to install speedtest-cli utility. So to install this package on CentOS/RHEL 7 based systems you need to use yum install python3-pip command as shown below.

NOTE:

Please note that here I am using root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.
[root@localhost ~]# yum install python3-pip
Resolving Dependencies
--> Running transaction check
---> Package python3-pip.noarch 0:9.0.3-8.el7 will be installed
--> Processing Dependency: python(abi) = 3.6 for package: python3-pip-9.0.3-8.el7.noarch
--> Processing Dependency: python3-setuptools for package: python3-pip-9.0.3-8.el7.noarch
--> Processing Dependency: /usr/bin/python3 for package: python3-pip-9.0.3-8.el7.noarch
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-18.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-18.el7 for package: python3-3.6.8-18.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-18.el7.x86_64
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-18.el7 will be installed
--> Processing Dependency: libtirpc.so.1()(64bit) for package: python3-libs-3.6.8-18.el7.x86_64
--> Running transaction check
---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed
--> Finished Dependency Resolution

In case you are using older CentOS/RHEL version then you can install it using yum install python-pip command as shown below.

[root@localhost ~]# yum install python-pip

Similarly for Ubuntu/Debian based systems you can use either apt-get install python3-pip or apt-get install python-pip command based on your ubuntu/debian version.

apt-get install python-pip3
apt-get install python-pip

 

Step 4: Install Speedtest CLI

Once pip3 utility is available, you can now install speedtest-cli using pip3 install speedtest-cli command as shown below.

[root@localhost ~]# pip3 install speedtest-cli
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting speedtest-cli
Downloading https://files.pythonhosted.org/packages/9f/39/65259b7054368b370d3183762484fa2c779ddc41633894d895f9d1720f45/speedtest_cli-2.1.3-py2.py3-none-any.whl
Installing collected packages: speedtest-cli
Successfully installed speedtest-cli-2.1.3

If you are using older version of pip utility then you can use pip install speedtest-cli command.

[root@localhost ~]# pip install speedtest-cli

 

Step 5: Check Speedtest-cli version

You can verify speedtest-cli installed version by using speedtest-cli --version command as shown below.

[root@localhost ~]# speedtest-cli --version
speedtest-cli 2.1.3
Python 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

 

Step 6: Test Your Internet Speed

You can simply run speedtest-cli command to test your Linux Internet speed as shown below. Here you will get important information about your local Internet Connection like download speed and upload speed.

[root@localhost ~]# speedtest-cli
Retrieving speedtest.net configuration...
Testing from Jio (100.40.69.86)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Synergy Internet (California) [0.17 km]: 84.413 ms
Testing download speed................................................................................
Download: 83.50 Mbit/s
Testing upload speed......................................................................................................
Upload: 24.27 Mbit/s

 

Step 7: Remove Speedtest CLI

Once you are done with the tool, you can simply uninstall it by using pip3 uninstall speedtest-cli command as shown below.

[root@localhost ~]# pip3 uninstall speedtest-cli
Uninstalling speedtest-cli-2.1.3:
/usr/local/bin/speedtest
/usr/local/bin/speedtest-cli
/usr/local/lib/python3.6/site-packages/__pycache__/speedtest.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/__pycache__/speedtest_cli.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/speedtest.py
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/INSTALLER
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/LICENSE
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/METADATA
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/RECORD
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/WHEEL
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/entry_points.txt
/usr/local/lib/python3.6/site-packages/speedtest_cli-2.1.3.dist-info/top_level.txt
/usr/local/lib/python3.6/site-packages/speedtest_cli.py
Proceed (y/n)? y
Successfully uninstalled speedtest-cli-2.1.3

If you are using older version of pip utility then you can use pip uninstall speedtest-cli command to remove Speedtest CLI.

[root@localhost ~]# pip uninstall speedtest-cli

1 thought on “How to Install and Use Speedtest CLI to Test Internet Speed on Linux”

Leave a Comment