Many times to check our Internet speed we used to use a speedtest website to measure our network speed. Instead of using the utility from the web now, you have the option to use it from the terminal using Speedtest CLI.
[ You might also like: How to Check CPU Information in Linux ]
Speedtest CLI is a command-line utility for system administrators, software developers, and computer users to measure their Internet download and upload speed, latency, and packet loss from the Linux terminal. This utility is written in Python and you need Python 2.4 and above to make it work.
How to Install Speedtest CLI in Linux
There are many ways to install Speedtest CLI in your Linux distribution. There are common ways that can be used irrespective of the distribution you are using or you can use your distribution package manager to install the package as shown.
Install Speedtest CLI in Debian/Ubuntu & Mint
$ curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash $ sudo apt-get install speedtest
Install Speedtest CLI in Redhat/Fedora & CentOS
$ curl -s https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash $ sudo yum install speedtest
Install Speedtest CLI Using PIP in Linux
Alternatively, you can install the Speedtest CLI package using PIP or downloading a package from GitHub. To install the package via pip run the following command. Depending upon how you configured pip in your machine you have to either use pip or pip3.
$ pip install speedtest-cli OR $ pip3 install speedtest-cli
Install Speedtest CLI from GitHub in Linux
To download and install the package from GitHub run the following command.
$ git clone https://github.com/sivel/speedtest-cli.git $ cd speedtest-cli $ python setup.py install
Once installed, you can verify if the installation is successful by running:
$ speedtest-cli --version speedtest-cli 2.1.3 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
How to Use Speedtest CLI in Linux Terminal
--help to get a list of flags available to use along with the utility.
$ speedtest-cli --help
Check Linux Internet Speed
To measure your internet speed run the following command. From the below image you can see this command measures your internet upload and download speed.
Check Linux Internet Download and Upload Speed
You can choose to test only upload or download speed by adding the below flags.
$ speedtest-cli --no-download [Do not perform download test] $ speedtest-cli --no-upload [Do not perform upload test]
If you look at the output it gives a lot of verbose which can be simply omitted using the
$ speedtest-cli --simple
You can also get output in JSON format by adding the
$ speedtest-cli --json
Check List of Speed Net Servers
You can get the list of speed net servers by running the following command. The list will be sorted by distance.
$ speedtest-cli --list $ speedtest-cli | wc -l # Total server count
That’s it for this article. This Speedtest CLI tool will come in handy when you want to measure your Linux server internet speed when writing any scripts.