- Run an Internet Speed Test from the Linux Command Line
- Different Speed Test Packages
- Unofficial Speedtest-CLI Python Script
- Official Ookla Speedtest CLI
- The Speedtest-cli Python Script
- Installing the Speedtest-cli Python Script
- Install on Fedora using DNF
- Ubuntu or Debian using APT
- CentOS/Red Hat 7 / 8
- How to Use the Python Script to Run a Speed Test
- Speedtest-cli Python Script Options
- List Available Speed Test Servers
- Specify Specific Server to Test Against
- Only Test Upload or Download Speeds
- Format Output in JSON or CSV
- The Official Ookla Speedtest CLI
- Installing the Official Speedtest CLI
- Install Speedtest CLI on Ubuntu / Debian:
- Install Speedtest CLI on Fedora / Redhat / CentOS:
- How to Use the Official Speedtest CLI
- Official Speedtest CLI Options
- List Available Speed Test Servers
- Select Specific Server to Run Speed Test Against
- Change Unit Used for Speed Output
- Output Formatting Options
- Conclusion
- HowTo: TEST Internet Speed via Linux Command Line
- Test Download/Upload Internet Speed in Linux
- Test Internet Speed From the Linux Command Line
- Share the Result Of Speed Test via Speedtest.net
- Get the List Of Available Speedtest.net Servers
- Measure the Network Speed to Specific Server
- How to Test Your Linux Internet Speed Using Speedtest CLI
- What is Speedtest-cli
- Install speedtest-cli in Linux
- On this page
- Install speedtest-cli Using Python PIP
- Install speedtest-cli Using Python Script
- Install speedtest-cli Using Package Manager
- Testing Linux Internet Connection Speed with speedtest-cli
- Conclusion
- If You Appreciate What We Do Here On TecMint, You Should Consider:
Run an Internet Speed Test from the Linux Command Line
We have all used tools like speedtest.net to test upload and download speeds. Whether it was to test the WiFi in that coffee shop (I use my own tether, never unknown hot spots), preparing for a LAN party (do people still do that?), or just a step in troubleshooting, we have all been there. For one reason or another you simply think you are being cheated of bandwidth, so you want independent verification of your speeds. This typically means opening a browser and going to a website to test your connection. But what if you want to run a speed test on a remote server? In this article we will discuss running an internet speed test from the Linux command line, and skipping the browser.
There is something about the raw efficiency of the command line that I am really attracted to. As I discussed in the article “5 Command Line Tool to Break Your Dependence on the GUI“, I try my best to stay away from the browser. It usually creates an unnecessary distraction. The internet is designed to grab your attention like a laser pointer does to a cat. So let’s get started, and figure out one more way to stay away from the GUI.
Different Speed Test Packages
There are a few different tools you can use to run a speed test from the command line. To make things even more confusing the two most popular share the same exact name, but both use the speedtest.net service.
Unofficial Speedtest-CLI Python Script
The first one is an independently written Python script that is simple to install and use. It is available in the default repositories for some popular Linux distributions.
Pros:
- Easy to install
- Wide Availability
- Full list of servers
- Can specify upload test, download test, or both
Cons:
- Minimal output format options
- No verbose output option
Official Ookla Speedtest CLI
The second tool is built by Ookla, the people who bring you the speedtest.net website and service. Installing it requires you to add a repo for your package manager. But the maintainers offer simple instructions for installation.
Pros:
- Official release from Ookla
- More robust formatting options
- Output easier to read, better layout
- Verbose output available
- Has repo making it easy to get updates
Cons:
- Use limited to nearby servers
- Cannot specify download or upload only
The Speedtest-cli Python Script
This is an easy way to get started running a speed test on the Linux command line.
Installing the Speedtest-cli Python Script
Simply use your package manager to install the package.
Install on Fedora using DNF
Ubuntu or Debian using APT
CentOS/Red Hat 7 / 8
Unfortunately, CentOS does not offer the rpm in their repos. It can still be easily installed.
Change to /usr/bin directory to make command available to all users:
Fetch script from github:
Make script executable:
Or just copy and paste the whole thing below as a single line:
How to Use the Python Script to Run a Speed Test
The most basic usage is to simply run the command. It will automatically select the best server based on ping responses.
Speedtest-cli Python Script Options
There are several options available to change the default behavior. Here we will outline the most popular options.
List Available Speed Test Servers
You can use the –list option to find a list of available servers to run your test against. At the time of writing this list is pretty extensive with 8829 possible servers.
NOTE: The servers are sorted by distance, closest first.
Specify Specific Server to Test Against
Once you have found the server you want to test against, you can use the –server to select it. The server ID is the first column in the output of the list option above.
Only Test Upload or Download Speeds
The option is actually designed to exclude a test. But since there are only two options it is effectively the same as selecting only one. To run only the download test, you exclude the upload, and vice versa.
Format Output in JSON or CSV
You can specify the output format in JSON or CSV. You also have the opton to use CSV with a custom delimiter. This is handy if you are going to use the output in some other script or application.
Using CSV with a custom delimiter. The default delimiter is a comma, which is implied by the name CSV. Here we use the –csv-delimiter option to change the delimiter to a pipe character.
The Official Ookla Speedtest CLI
The official Speedtest CLI (Command Line Interface) from Ookla is a little more robust. It has all of the options of the python script and more. There are also several output formats not available with the unofficial python script.
Ookla’s speedtest is also a little easier on the eyes. It spreads the information out which makes it easier to read and displays a neat little progress bar. A URL you can use to share the results is also displayed by default.
Installing the Official Speedtest CLI
Install Speedtest CLI on Ubuntu / Debian:
The Speedtest CLI from Ookla is supported on Ubuntu (xenial & bionic) and Debian (jessie, stretch, buster).
Install Speedtest CLI on Fedora / Redhat / CentOS:
Fedora has moved on to DNF for package management, but is still compatible with YUM. These instructions were tested on Fedora 31, CentOS 7 and Red Hat 8.
How to Use the Official Speedtest CLI
Once installed you can simply call the utility by typing “speedtest” at the command line. This will give you all the default information that you would see on the web version of speedtest.net.
Official Speedtest CLI Options
The options available in the official release are more robust. Here we will outline the popular options and how to use them.
List Available Speed Test Servers
Using the -L (–servers) option will give you a list of servers available to run a test against. This option will only show you servers that are “nearby”. What exactly determines nearby is undefined. But for me it looks like they are staying in the tri-state area (PA, NJ, DE).
Optionally, you can use the -o (–host) option and specify the FQDN of the server instead of the ID. But oddly, I don’t see a way to get the FQDN of the servers on the list. I am guessing this option is available for using a custom server.
I haven’t found a way to list all servers. If you are looking to test against a server on the other side of the country, you will have to find it another way.
Select Specific Server to Run Speed Test Against
You can use the -s (–server-id) option to select a server to use from the list. You must supply the server ID with this option. The server ID is the number in the first column of the list output above.
Change Unit Used for Speed Output
The -u (–unit) option can display the speed output in many different formats.
Decimal prefix, bits per second: bps, kbps, Mbps, Gbps
Decimal prefix, bytes per second: B/s, kB/s, MB/s, GB/s
Binary prefix, bits per second: kibps, Mibps, Gibps
Binary prefix, bytes per second: kiB/s, MiB/s, GiB/s
Output Formatting Options
The Ookla Speedtest CLI offers decent options for output formats.
- Human Readable – Default
- CSV – Comma Separated Value
- TSV – Tab Separated Value
- JSON – JavaScript Object Notation
- JSONL – JSON Lines
- JSON-PRETTY – JSON Pretty Printed
Here is an example using json-pretty.
Conclusion
Running a speed test from the command line may not be something that is needed on a daily basis for most people. However, it may prove useful in some troubleshooting situations.
In this article we cover how to run a speed test from the command line using two similar tools. The unofficial python script and the official Ookla Speedtest CLI. We discussed installing, using and setting options for each one. This should be enough to get you started.
For more information on these tools, visit their respective home pages found in the resources section below.
Источник
HowTo: TEST Internet Speed via Linux Command Line
If you need to troubleshoot an issue with slow Internet access on your Linux system, it would be a good idea to measure the current Internet speed.
In this article you’ll find how to test Internet speed from the Linux terminal, using speedtest_cli – a simple command-line client written in Python for measuring Internet bandwidth by using Speedtest.net infrastructure.
I’ll show how to simply check download/upload Internet speed to the geographically closest server, how to measure the network speed to specific server and how to share the results of speed test via Speedtest.net.
All these tasks can be performed using the Linux command line only.
Test Download/Upload Internet Speed in Linux
Use the following command to Test Internet Download and Upload Speed from the Linux Command Line:
Test Internet Speed From the Linux Command Line
If you are planing to measure Internet bandwidth often, you can install speedtest script on your system:
After installation, you will be able to test Internet speed from the terminal by simply running speedtest command, as follows:
Share the Result Of Speed Test via Speedtest.net
If you want to share the result of speed test, run speedtest command, as follows:
Get the List Of Available Speedtest.net Servers
Run the following command to get the list of all available Speedtest.net servers around the world:
Measure the Network Speed to Specific Server
You can manually specify server ID during testing, instead of using the geographically closest one.
Let’s test the link to “1746) Vodafone DE (Frankfurt, Germany) [1937.90 km]”:
Источник
How to Test Your Linux Internet Speed Using Speedtest CLI
We always need to check the speed of the Internet connection at home and office. What do we do about this? Go to websites like Speedtest.net and begin the test. It loads JavaScript in the web browser and then selects the best server based upon ping and outputs the result. It also uses a Flash player to produce graphical results.
What about a headless server, where isn’t any web-based browser and the main point is, most of the servers are headless. Another bottleneck of such web browser-based speed testing is that you can’t schedule the speed testing at regular intervals.
Here comes an application “Speedtest-cli” that removes such bottlenecks and lets you test the speed of Internet connection from the command line.
What is Speedtest-cli
The application is basically a script developed in the Python programming language. It measures Internet Bandwidth speed bidirectionally. It uses speedtest.net infrastructure to measure the speed. Speedtest-cli is able to list servers based upon physical distance, test against the specific servers, and gives you a URL to share the result of your internet speed test.
To install the latest speedtest-cli tool in Linux systems, you must have Python 2.4-3.4 or a higher version installed on the system.
Install speedtest-cli in Linux
There are three ways to install the speedtest-cli tool. The first method involves the use of python-pip package while the second method is to download the Python script, make it executable and run it and the third method is to use the package manager. Here I will cover all ways…
On this page
Let’s get started…
Install speedtest-cli Using Python PIP
First, you need to install the python-pip package, then afterward you can install the speedtest-cli tool using the pip command as shown below.
Install PIP in Debian/Ubuntu/Mint
Install PIP in CentOS/RHEL
Install PIP in Fedora
Install PIP in openSUSE
Install PIP in Arch Linux
Once pip has been installed, you can install the speedtest-cli tool.
To upgrade speedtest-cli, at a later stage, use.
Install speedtest-cli Using Python Script
First, download the python script from Github using the wget command or curl command and make the script file executable.
Next, move the executable to /usr/bin folder, so that you don’t need to type the full path every time.
Install speedtest-cli Using Package Manager
You can also install speedtest-cli using your default package manager as shown.
Testing Linux Internet Connection Speed with speedtest-cli
1. To test the Download and Upload speed of your internet connection, run the speedtest-cli command without any argument as shown below.
Check Linux Download and Upload Speed
2. To check the speed result in bytes in place of bits.
Check Linux Internet Speed in 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.
Share Linux Internet Speed Test Results
The following picture is a sample speed test result generated using the above command.
View Linux Internet Speed Test Results
4. Don’t need any additional information other than Ping, Download, and Upload?
Test Linux Internet Speed
5. List the speedtest.net server-based upon physical distance. The distance in km is mentioned.
List Speedtest Servers
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).
List Nearest Speedtest Servers
7. Test connection speed against a specific server. Use Server Id generated in example 5 and example 6 in above.
Test Linux Internet Speed Against Server
8. To check the version number and help of speedtest-cli a tool.
Speedtest Version and Help
Note: Latency reported by the tool is not its goal and one should not rely on it. The relative latency values output is responsible for the server selected to be tested against. CPU and Memory capacity will influence the result to a certain extent.
Conclusion
The tool is a must for system administrators and developers. A simple script that 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.
That’s all for now, till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in the comments below. Like and share us and help us get spread.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник