How to check internet speed from command line using Speedtest CLI tool

To check internet speed from command line using Speedtest CLI tool

In this article we will discuss how to check internet speed from command line using Speedtest CLI tool. Speedtest-cli tool is a script developed in Python programming language which measures the bandwidth speed bidirectionally.

To install speedtest-cli Using Python Script

Example

[user1@linuxhelp Desktop]$ wget https://github.com/sivel/speedtest-cli/archive/master.zip
--2016-03-05 02:41:08--  https://github.com/sivel/speedtest-cli/archive/master.zip
Resolving github.com... 192.30.252.131
Connecting to github.com|192.30.252.131|:443... connected..
...
...
Saving to: “ master.zip” 

100%[======================================> ] 17,653      65.9K/s   in 0.3s    

2016-03-05 02:41:10 (65.9 KB/s) - “ master.zip”  saved [17653/17653] 

[user1@linuxhelp Desktop]$ unzip master.zip 
Archive:  master.zip
7b09d8759fcbbda8a71aa49a4eaa825581b07439
   creating: speedtest-cli-master/
  inflating: speedtest-cli-master/.gitignore  
  inflating: speedtest-cli-master/.travis.yml  
  inflating: speedtest-cli-master/CONTRIBUTING.md
  ...
  ...
  inflating: speedtest-cli-master/speedtest_cli.py  
  inflating: speedtest-cli-master/tox.ini  

To make the script file executable

Example

[root@linuxhelp Desktop]# cd speedtest-cli-master/
[root@linuxhelp speedtest-cli-master]# chmod 755 speedtest_cli.py

To move the executable to /usr/bin folder

Example

[root@linuxhelp speedtest-cli-master]# mv speedtest_cli.py /usr/bin/


To test the speed of your internet connection

Run the following speedtest-cli command without any argument as shown below.

Syntax
speedtest_cli.py

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Bharti Airtel (125.17.109.94)...
Selecting best server based on latency...
Hosted by Mahanagar Telephone Nigam Ltd (Mumbai) [1.15 km]: 48.827 ms
Testing download speed........................................
Download: 5.14 Mbit/s
Testing upload speed..................................................
Upload: 5.46 Mbit/s

To check the speed result in bytes

Syntax
speedtest_cli.py --bytes

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --bytes
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Bharti Airtel (125.17.109.94)...
Selecting best server based on latency...
Hosted by Mahanagar Telephone Nigam Ltd (Mumbai) [1.15 km]: 38.251 ms
Testing download speed........................................
Download: 0.67 Mbyte/s
Testing upload speed..................................................
Upload: 0.68 Mbyte/s

To share your bandwidth speed with others

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Bharti Airtel (125.17.109.94)...
Selecting best server based on latency...
Hosted by Mahanagar Telephone Nigam Ltd (Mumbai) [1.15 km]: 42.625 ms Testing download speed........................................
Download: 4.78 Mbit/s
Testing upload speed..................................................
Upload: 5.38 Mbit/s
Share results: http://www.speedtest.net/result/5140591446.png

For information about Download and upload

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --simple
Ping: 41.498 ms
Download: 5.34 Mbit/s
Upload: 5.42 Mbit/s

To list the speedtest.net server based upon physical distance

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --list
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
1827) Vodafone India (New Delhi, India) [3.13 km]
4156) MTS india (New Delhi, India) [3.13 km]
5727) Excitel (New Delhi, India) [3.13 km]
2608) Bharti Airtel Ltd (New Delhi, India) [3.13 km]
2812) Aircel (New Delhi, India) [3.13 km]
7847) Citycom Networks Pvt Ltd (New Delhi, India) [3.13 km]
7859) Ten to Ten (New Delhi, India) [3.13 km]
7382) Star Broadband Services (I) Pvt Ltd (New Delhi, India) [3.13 km]
6937) VeriVoz Communication Private Limited (New Delhi, India) [3.13 km]
8016) Spectranet (New Delhi, India) [3.13 km]
8031) Zapbytes Technologies Pvt. Ltd. (New Delhi, India) [3.13 km]
6588) YPT Entertainment House P. LTd. (New Delhi, India) [3.13 km]
7075) FusionNet (Noida, India) [12.18 km]
5369) Reliance Communication Limited (Gurgaon, India) [22.02 km]
6431) YOU Broadband India Pvt Ltd. (Gurgaon, India) [22.02 km]
4183) Tripleplay Broadband Pvt Ltd (Gurgaon, India) [22.02 km]
3377) Nextra Teleservices Pvt. Ltd. (Gurgaon, India) [22.02 km]
6936) RailTel (Gurgaon, India) [22.02 km]
7569) IriisNet Communication Pvt. Ltd. (Faridabad, India) [22.51 km]
5715) True Broadband Service (Ghaziabad, India) [22.84 km]

To get desired output

To see the speedtest.net server located in Mumbai, run the following command

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --list | grep -i Mumbai
1718) Vodafone India (Mumbai, India) [1159.84 km]
5060) Mahanagar Telephone Nigam Ltd (Mumbai, India) [1159.84 km]
2938) Reliance Communications (Mumbai, India) [1159.84 km]
6403) YOU Broadband India Pvt Ltd., Mumbai (Mumbai, India) [1159.84 km]
6454) YOU Broadband India Pvt Ltd. (Mumbai, India) [1159.84 km]
2827) Bharti Airtel Ltd (Mumbai, India) [1159.84 km]
4641) Reliance Jio Infocomm Ltd (Mumbai, India) [1159.84 km]
7950) SoftCall Coc Pvt Ltd (Mumbai, India) [1159.84 km]
7605) Idea Cellular Ltd. (Mumbai, India) [1159.84 km]
5965) HOME NET (Mumbai, India) [1159.84 km]
7838) Intech Online Pvt Ltd (Mumbai, India) [1159.84 km]
4883) Wan &  Lan Internet Pvt. Ltd. (Mumbai, India) [1159.84 km]
6746) SevenStar pvt ltd. (Mumbai, India) [1159.84 km]
7002) BSNL (Mumbai, India) [1159.84 km]
6675) Vovinet Broadband Pvt. Ltd. (Mumbai, India) [1159.84 km]

To test connection speed against a specific server

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --server 7631
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Bharti Airtel (125.17.109.94)...
Hosted by WOM Chile (Santiago) [16917.19 km]: 650.931 ms
Testing download speed........................................
Download: 3.14 Mbit/s
Testing upload speed..................................................
Upload: 3.85 Mbit/s

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

speedtest_cli.py --version

Example

[user1@linuxhelp Desktop]$ speedtest_cli.py --version
0.3.4
5140591446
speedtest_cli.py --help

[user1@linuxhelp Desktop]$ speedtest_cli.py --help
usage: speedtest_cli.py [-h] [--bytes] [--share] [--simple] [--list]
                        [--server SERVER] [--mini MINI] [--source SOURCE]
                        [--timeout TIMEOUT] [--secure] [--version]

Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli

optional arguments:
  -h, --help         show this help message and exit
  --bytes            Display values in bytes instead of bits. Does not affect
                     the image generated by --share
  --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
  --timeout TIMEOUT  HTTP timeout in seconds. Default 10
  --secure           Use HTTPS instead of HTTP when communicating with
                     speedtest.net operated servers
Tag : Speed test
FAQ
Q
What command is used to check in selective location?
A
That location must be your surrounding you can grep them and see "speedtest_cli.py --list | grep -i Mumbai"
Q
How to view the list of available options available in it?
A
Use help option speedtest_cli.py --help
Q
What option is used to get report regarding upload and download?
A
You can make use of the following speedtest_cli.py --simple
Q
How long the distance covers while listing the distance?
A
It covers almost top process (in terms of location)
Q
How to test the connection against speed of certain server?
A
With the help of following command speedtest_cli.py --server 7631