How to test Internet Speed from Linux Terminal

To test Internet Speed from Linux Terminal

This article explains, how to test Internet Speed from Linux Terminal. Normally to calculate the internet speed we use websites from the web browser. The speed can also be checked in the terminal by using a script file called “ speedtest-cli” .

Execute the below command to download the script file from github.com

root@linuxhelp:~# wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
--2016-07-06 09:35:01--  https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
Resolving raw.github.com (raw.github.com)... 151.101.100.133
Connecting to raw.github.com (raw.github.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py [following]
--2016-07-06 09:35:02--  https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24994 (24K) [text/plain]
Saving to: ‘ speedtest-cli’ 

speedtest-cli       100%[=====================> ]  24.41K   109KB/s   in 0.2s   

2016-07-06 09:35:03 (109 KB/s) - ‘ speedtest-cli’  saved [24994/24994]
root@linuxhelp:~# ls
Desktop    Downloads         Music     Public         Templates
Documents  examples.desktop  Pictures  speedtest-cli  Videos

You can view the content of the script file by typing the below command.

root@linuxhelp:~# cat speedtest-cli

Set execute permission for the script.

root@linuxhelp:~# ls -l
total 72
drwxr-xr-x 2 user1 user1  4096 Jul  2 10:49 Desktop
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Documents
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Downloads
-rw-r--r-- 1 user1 user1  8980 Apr 22 22:51 examples.desktop
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Music
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Pictures
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Public
-rw-r--r-- 1 root  root  24994 Jul  6 09:35 speedtest-cli
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Templates
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Videos
root@linuxhelp:~# chmod +x speedtest-cli
root@linuxhelp:~# ls -l
total 72
drwxr-xr-x 2 user1 user1  4096 Jul  2 10:49 Desktop
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Documents
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Downloads
-rw-r--r-- 1 user1 user1  8980 Apr 22 22:51 examples.desktop
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Music
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Pictures
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Public
-rwxr-xr-x 1 root  root  24994 Jul  6 09:35 speedtest-cli
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Templates
drwxr-xr-x 2 user1 user1  4096 Apr 22 22:58 Videos

To start the speed test, execute the below command.

root@linuxhelp:~# ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Airtel (125.17.109.94)...
Selecting best server based on latency...
Hosted by YOU Broadband India Pvt. Ltd (Pune) [236.78 km]: 84.498 ms
Testing download speed........................................
Download: 4.95 Mbit/s
Testing upload speed..................................................
Upload: 5.31 Mbit/s

Run the following command, to share the test result in speedtest.net.

root@linuxhelp:~# ./speedtest-cli --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Airtel (125.17.109.94)...
Selecting best server based on latency...
Hosted by YOU Broadband India Pvt. Ltd (Pune) [236.78 km]: 38.122 ms
Testing download speed........................................
Download: 4.87 Mbit/s
Testing upload speed..................................................
Upload: 5.19 Mbit/s
Share results: http://www.speedtest.net/result/5455817490.png

Open the browser and paste the " Share results" link to view the result.

To view the total list of speedtest servers, execute the following command.

root@linuxhelp:~# ./speedtest-cli --list
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
7800) Omkar Infotech (Latur, India) [104.77 km]
8337) Fibergrid (Sangareddy, India) [229.56 km]
8581) Fibergrid (Bodhan, Telangana, India) [234.81 km]
6404) YOU Broadband India Pvt. Ltd (Pune, India) [236.78 km]
6344) Tata Technologies (Pune, India) [236.78 km]
6993) BSNL (Pune, India) [236.78 km]
.
.
.
4839) Telefonica del Peru (Lima, Peru) [17043.68 km]
3455) America Movil Peru SAC (Lima, Peru) [17043.68 km]
4245) Wigo S.A (Lima, Peru) [17043.68 km]
5272) Fiberluxperu (Lima, Peru) [17043.68 km]
3611) OLO del Peru (Lima, Peru) [17043.68 km]
4921) VOY (Lima, Peru) [17043.68 km]
8370) Convergia Networks Inc (Lima, Peru) [17043.68 km]
6535) ColinaNet SRL. (Lima, Peru) [17043.68 km]
6615) Directv Peru (Lima, Peru) [17043.68 km]

To check the internet speed for a specific server.

root@linuxhelp:~# ./speedtest-cli --server 1858
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Airtel (125.17.109.94)...
Hosted by Entel (Santiago) [16255.46 km]: 553.989 ms
Testing download speed........................................
Download: 1.49 Mbit/s
Testing upload speed..................................................
Upload: 2.87 Mbit/s

To know more about speedtest-cli, run the following command.

root@linuxhelp:~# ./speedtest-cli --help
usage: speedtest-cli [-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
  --version          Show the version number and exit
FAQ
Q
What is the need to test the internet speed?
A
1. Normally to calculate the internet speed we use websites from the web browser.
2. The speed can also be checked in the terminal by using a script file called &ldquo speedtest-cli&rdquo .
Q
How to test Internet Speed from Linux Terminal?
A
Execute the below command to download the script file from github.com
# wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
Q
Can view the content of the script file?
A
By typing the below command.
# cat speedtest-cli
Q
How to set the execute permission for a script?
A
Set execute permission for the script use this command
# ls -l
Q
How to check the internet speed for a specific server?
A
Run the following command to check the internet speed for a specific server
# ./speedtest-cli --server 1858