We always need to check the speed of the Internet connection at home and . What we do for this? Go to websites like Speedtest.net and begin test. It loads JavaScript in the web browser and then select best based upon ping and output the result. It also uses a Flash player to produce graphical results.

What about headless server, where isn’t any web based browser and the main point is, most of the servers are headless. The another bottleneck of such web browser based speed testing is that, you can’t schedule the speed testing at regular interval. Here comes an application “Speedtest-cli” that removes such bottlenecks and let you test the speed of Internet connection from line.

What is Speedtest-cli

The application is basically a script developed in programming Language. It measures Internet Bandwidth speed bidirectionally. It used speedtest.net infrastructure to measure the speed. Speedtest-cli is able to list server based upon physical distance, test against specific server, and gives you URL to the result of your internet speed test.

To latest speedtest-cli tool in systems, you must have Python 2.4-3.4 or higher version installed on the system.

Install speedtest-cli in Linux

There are two ways to install speedtest-cli tool. The first method involves the use of python-pip package while the second method is to the Python script, make it executable and run, here I will cover both ways….

Install speedtest-cli Using pythin-pip

First you need to install python-pip package, then afterwards you can install the speedtest-cli tool using pip command as shown below.

$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli

To upgrade speedtest-cli, at later stage, use.

$ sudo pip install speedtest-cli –upgrade


Install speedtest-cli Using Python Script

First download the python script from github using wget command, unpack the downloaded file (master.zip) and extract it..

$ wget https://github.com/sivel/speedtest-cli/archive/master.zip
$ unzip master.zip 

After extracting the file, go to the extracted directory speedtest-cli-master and make the script file executable.

$ cd speedtest-cli-master/
$ chmod 755 speedtest_cli.py 

Next, move the executable to /usr/bin folder, so that you don’t need to type the full path everytime.

$ sudo mv speedtest_cli.py /usr/bin/

Testing Internet Connection Speed with speedtest-cli

1. To test Download and Upload speed of your internet connection, run the speedtest-cli command without any argument as shown below.

$ speedtest_cli.py


2. To check the speed result in bytes in place of bits.

$ speedtest_cli.py --bytes


3. Share your bandwidth speed with your friends or family. You are provided with a link that can be used to download an image.


The following picture is a sample speed test result generated using above command.


4. Don’t need any additional information other than Ping, Download and upload?

$ speedtest_cli.py --simple


5. List the speedtest.net server based upon physical distance. The distance in km is mentioned.

$ speedtest_cli.py --list


6. The last stage generated a huge list of servers sorted on the basis of distance. How to get desired output? Say I only want to see the speedtest.net server located in Mumbai (India).

$ speedtest_cli.py --list | grep -i Mumbai


7. Test connection speed against a specific server. Use Server Id generated in example 5 and example 6 in above.

$ speedtest_cli.py --server [server ID]
$ speedtest_cli.py --server [5060]              ## Here server ID 5060 is used in the example.


8. To check the version number and help of speedtest-cli tool.

$ speedtest_cli.py --version


$ speedtest_cli.py --help
./speedtest_cli.py --help
Usage: speedtest_cli.py [options]
Command line interface for testing internet bandwidth using speedtest.net.
  -h, --help       show this help message and exit
  --share          Generate and provide a URL to the speedtest.net share
                   results image
  --simple         Suppress verbose output, only show basic information
  --list           Display a list of speedtest.net servers sorted by distance
  --server=SERVER  Specify a server ID to test against
  --mini=MINI      URL of the Speedtest Mini server
  --source=SOURCE  Source IP address to bind to
  --version        Show the version number and exit

Note: Latency reported by tool is not its goal and one should not rely on it. The relative latency values output is responsible for server selected to be tested against. and Memory capacity will the result to certain extent.


The tool is must for system administrators and developers. A simple script which runs without any issue. I must say that the application is wonderful, lightweight and do what it promises. I disliked Speedtest.net for the reason it was using flash, but speedtest-cli gave me a reason to love them.

speedtest_cli is a third party application and should not be used to automatically record the bandwidth speed. Speedtest.net is used by millions of users and it is a good idea to Set Your Own Speedtest Mini Server.

Print Friendly, PDF & Email



Bài viết liên quan