Test Linux Internet Connection with Speedtest-Cli (Tips & Tricks)

Speedtest-Cli in an awesome Linux tool for anyone who works on networks. It can come in handy to have the ability to do a speedtest through the cli, or command line. Whether working on a server, VPS or even a desktop environment, you’ll find this tool is a great diagnostic. It is useful in both being a benchmark standard to hold your application to as well as a diagnostic tool that can help you figure out where something went wrong. In this article I’ll be showing you how to use this tool in any circumstance you may need it.

Installing speedtest-cli

Speedtest-cli can be downloaded and installed both from most package management systems (apt, yum, pacman, etc.) as well as the python package manager pip.

Pip

pip install speedtest-cli 

Ubuntu/Debian

sudo apt install speedtest-cli

Using speedtest-cli

This tool has lots of great functionality but don’t let that intimidate you. here we can test out the most basic form of the command

alex@sudoadmins:~$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from AT&T U-verse ([my IP was here])...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by CyberLynk Network ([my location]) [2.70 km]: 32.766 ms
Testing download speed..........................................
Download: 20.21 Mbit/s
Testing upload speed............................................
Upload: 2.18 Mbit/s

As you can see, we receive great and very detailed results even without specifying any options or flags. Nice!

In the command output, you should see your city or one near you. This is something you can change, try something like this

alex@sudoadmins:~$ speedtest-cli --list | grep "Chicago"

This command lists all of the locations that you can do speed tests from. As you can see, I’m piping the output of the command through grep to filter the results to only those that reference Chicago. This is the result I get:

19052) Syndeo Networks INC (Chicago, IL, United States) [130.49 km]
14228) Frontier (Chicago, IL, United States) [138.95 km]
17384) Windstream (Chicago, IL, United States) [138.95 km]
10670) Speedtest.net (Chicago, IL, United States) [138.95 km]
 2574) ServerCentral (Chicago, IL, United States) [138.95 km]
 1776) Comcast (Chicago, IL, United States) [138.95 km]
10135) CenturyLink (Chicago, IL, United States) [138.95 km]
 8705) Cable One, Inc. (Chicago, IL, United States) [138.95 km]
14489) QTS Data Centers (Chicago, IL, United States) [138.95 km]
18834) Sneaker Server (Chicago, IL, United States) [138.95 km]
18378) AT&T Wireless (Chicago, IL, United States) [138.95 km]
 5919) tzulo, inc (Chicago, IL, United States) [138.95 km]
19893) Access Media 3 (Chicago, IL, United States) [138.95 km]
 3084) SilverIP Communications (Chicago, IL, United States) [138.95 km]
11750) fdcservers.net (Chicago, IL, United States) [138.95 km]
15912) XenSpec (Chicago, IL, United States) [138.95 km]
21364) Enzu Inc. (Chicago, IL, United States) [138.95 km]
12012) Sprint (Chicago, IL, United States) [138.95 km]
20530) Metapeer (Chicago, IL, United States) [138.95 km]
22109) i3D.net (Chicago, IL, United States) [138.95 km]
23097) Whitesky Communications LLC (Chicago, IL, United States) [138.95 km]
24151) Verizon (Chicago, IL, United States) [138.95 km]
 7467) The Fusion Network (Chicago, IL, United States) [138.95 km]

Here we receive all of these connection points that we can test from, use the id number on the left to select them. I’ll use the first one that I see here, 19052. The –server option allows us to select this.

alex@sudoadmins:~$ speedtest-cli --server 19052
Retrieving speedtest.net configuration...
Testing from AT&T U-verse ([my IP])...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by Syndeo Networks INC (Chicago, IL) [130.49 km]: 30.355 ms
Testing download speed..........................................
Download: 14.89 Mbit/s
Testing upload speed............................................
Upload: 2.18 Mbit/s

Conclusion

The speedtest-cli command is a great test for internet connection from the command line. Because this tool is such a powerful diagnostic, it definitely deserves a place in your virtual toolbox. Not only is it quick and practical, it’s also got powerful and adaptable options that are so simple, anyone can use them.

1