1. Overview

In today’s fast-paced digital world, having a reliable and high-speed internet connection is essential. Whether a casual user, a developer, or a system administrator, monitoring our internet speed is crucial to ensure smooth online experiences.

In this tutorial, we’ll explore how to use speedtest-cli, a command-line tool, to check internet speed in Linux. speedtest-cli is a lightweight, fast, and easy-to-use utility that provides accurate measurements of our internet connection’s upload and download speeds.

2. What Is the speedtest-cli Command-Line Tool?

Before we delve into the installation and usage of speedtest-cli, let’s briefly understand what it is and how it works. speedtest-cli is a Python-based command-line interface for the popular Speedtest.net internet speed testing service. This tool allows us to measure our internet connection’s speed by connecting to the nearest Speedtest.net server and conducting a series of upload and download tests.

3. Installation

speedtest-cli is available as a Python package, and we can install it using pip:

$ sudo pip install speedtest-cli

Once the installation is complete, we can check the version of speedtest-cli by using the –version argument:

$ speedtest-cli --version

This will display the version of speedtest-cli that is currently installed on our system.

4. Performing a Speed Test

With speedtest-cli now installed on our system, we’re ready to perform a speed test, So, let’s open a terminal and run the program without any arguments:

$ speedtest-cli
Testing download speed................................................................................
Download: 106.32 Mbit/s
Testing upload speed......................................................................................................
Upload: 31.21 Mbit/s

Note that if the previous command returns a “403 Forbidden” error, we can use the –secure flag to force speedtest-cli to use HTTPS instead of HTTP when communicating with Speedtest.net servers.

5. Interpreting the Results

After running the speedtest-cli command, we’ll receive the test results as its output. This output will include details such as our public IP address, the server used for testing, and the ping (latency) time. The most crucial information, however, is the internet speed measurements.

5.1. Download Speed

The download speed represents how fast data can be pulled from the internet to our device. It’s measured in megabits per second (Mbps). A higher download speed indicates faster loading times for websites, quicker file downloads, and smoother streaming experiences.

5.2. Upload Speed

The upload speed, also measured in megabits per second (Mbps), represents how fast data can be sent from our device to the internet. This is essential for activities like uploading files, sending emails with attachments, and engaging in video calls.

6. Customizing speedtest-cli Options

speedtest-cli comes with various options that allow us to customize the testing experience. Let’s look at some of its most useful options.

6.1. Choosing a Specific Server

By default, speedtest-cli automatically connects to the nearest Speedtest.net server for testing. However, we can specify a particular server using its ID or name to conduct the speed test with that specific server:

$ speedtest-cli --server SERVER_ID_OR_NAME

We can get the list of available servers using the –list argument:

$ speedtest-cli --list

We should note that the list is sorted by distance in descending order — the topmost servers are the ones nearest to us.

6.2. Output in Different Formats

If we need to process the speed test results programmatically or save them to a file, we can use available output formats like JSON or CSV:

$ speedtest-cli --json
$ speedtest-cli --csv

We should note that when using CSV format, the speed is always measured in bits per second. In addition, we can use the –csv-header option to print the column names header.

6.3. Sharing the Test Results

It’s easy to share the test results with others via a public results-sharing service from Speedtest.net by invoking the command with the –share option:

$ speedtest-cli --share

Basically, this will upload our test results to Speedtest.net and generate a unique URL that we can share with others. Accordingly, the URL will display the details of our test results, including the download and upload speeds, ping time, and server location.

7. Conclusion

As we’ve seen in this article, speedtest-cli is a powerful, versatile, and user-friendly tool that can help us measure and monitor our internet connection’s performance in Linux. Whether we’re casual users, developers, or system administrators, having a reliable and fast internet connection is key to ensuring smooth online experiences.

We’ve explored how we can quickly and easily perform speed tests, customize the testing experience, and share our test results with others. As a result, by using this tool, we can identify potential issues, troubleshoot problems, and optimize our internet connection’s performance for the best online experience possible.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.