Test speed of internet connection in command line

Suppose you are running a Linux based VPS, how can you run a test to check the speed of your data connection to internet?
Here we will show a simple solution of how to test Internet connection speed for a Linux instance from command line.

The python script speedtest-cli is designed for this,and it’s the one that we highly recommended. Speedtest-cli interfaces with the popular website Speedtest.net, it supplies enough features for you to conduct an Internet Speed test.

Install Speedtest-cli

The installation is easy, you basically need to run these commands;

wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
sudo install -oroot -groot -m 755 speedtest_cli.py /usr/local/bin/speedtest-cli

Run Speedtest-cli
When you run speedtest-cli without any parameters, it will automatically find out the nearest speedtest.net servers and run a speed test. You can check an example output as below,

root@admon:~# speedtest-cli
Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from Digital Ocean (107.170.7.29)…
Selecting best server based on ping…
Hosted by Interserver, inc (Secaucus, NJ) [8.55 km]: 22.252 ms
Testing download speed………………………………….
Download: 72.95 Mbit/s
Testing upload speed…………………………………………..
Upload: 89.42 Mbit/s

There are several parameters that may have your attention. “–list” can be used to list all speedtest.net test servers. Currently there are more than 2500 servers in the list, each of these servers has an ID, with the id we can use the “–server” parameter to specify which server should we use for testing. “–share” will generate a graphical image of your test run result and upload it to speedtest.net, so that you can share it somewhere.

root@admon:~# speedtest-cli --list | head
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
663) Optimum Online (New York City, NY, United States) [1.56 km]
3593) Inerail (New York City, NY, United States) [1.56 km]
1819) Towerstream (New York City, NY, United States) [1.56 km]
2947) Atlantic Metro (New York City, NY, United States) [1.56 km]
982) Interserver, inc (Secaucus, NJ, United States) [8.55 km]
3589) FortressITX (Clifton, NJ, United States) [20.24 km]
3951) Era 2000 Management Ltd. (Matawan, NJ, United States) [39.84 km]
1258) Monmouth Telecom (Red Bank, NJ, United States) [42.60 km]

root@admon:~# speedtest-cli --server 663 --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.7.29)...
Hosted by Optimum Online (New York City, NY) [1.56 km]: 22.252 ms
Testing download speed........................................
Download: 698.59 Mbit/s
Testing upload speed..................................................
Upload: 247.44 Mbit/s
Share results: http://www.speedtest.net/result/3271863960.png
Share Button

Leave a comment

Your email address will not be published. Required fields are marked *