Speedtest CLI On Linux: A Quick Guide
Hey there, Linux enthusiasts! Ever wondered how to quickly check your internet speed directly from your terminal? Well, you're in the right place! In this guide, we'll dive into using the Speedtest CLI (Command Line Interface) on Linux. It's a super handy tool that lets you measure your internet speed without needing a web browser. Let's get started!
Why Use Speedtest CLI?
Before we jump into the how-to, let's talk about why you might want to use the Speedtest CLI in the first place. Here's the deal: sometimes, you just want a quick, no-nonsense way to check your internet speed. Opening a browser, navigating to a website, and dealing with all the ads and graphics can be a bit of a pain. The Speedtest CLI offers a clean, fast, and ad-free experience. Plus, it's perfect for scripting and automation. Imagine you want to monitor your internet speed regularly and log the results. With the CLI, you can easily create a script to do just that. It's also great for servers or headless systems where you don't have a graphical interface. Whether you're a sysadmin, a developer, or just a curious user, the Speedtest CLI can be a valuable addition to your toolkit.
Another significant advantage is its accuracy. Because it runs directly from your terminal, it eliminates many of the variables that can affect browser-based speed tests. This means you get a more reliable and consistent measurement of your actual internet speed. Furthermore, the CLI allows you to specify the server you want to test against, giving you even more control over the testing process. For instance, if you suspect issues with a particular server, you can target it directly to diagnose the problem. So, for those who need precise and repeatable results, the Speedtest CLI is the way to go. The ability to automate tests also makes it ideal for troubleshooting network issues over time, providing a clear picture of performance trends.
Moreover, the Speedtest CLI is incredibly lightweight and efficient. It doesn't hog system resources like a browser-based test might, making it perfect for systems with limited processing power. This is especially useful on older machines or embedded devices where every bit of performance counts. In addition, the CLI is highly configurable. You can customize various aspects of the test, such as the number of connections, the duration of the test, and the size of the data packets. This level of customization allows you to fine-tune the test to match your specific network conditions and testing requirements. For example, you might want to increase the number of connections to simulate heavy network usage or reduce the data packet size to test the performance of smaller packets. The flexibility and control offered by the Speedtest CLI make it an indispensable tool for anyone serious about network performance testing.
Installation
Okay, let's get this show on the road! Installing the Speedtest CLI on Linux is generally straightforward. Here’s how you can do it:
Using apt (Debian/Ubuntu)
If you're on a Debian-based system like Ubuntu, you can use apt to install the Speedtest CLI. First, you'll need to add the Ookla APT repository. Here’s how:
- 
Add the Ookla GPG key: curl -s https://ookla.bintray.com/ookla_bintray.gpg.key | sudo apt-key add -
- 
Add the Ookla repository: echo "deb https://ookla.bintray.com/debian generic stable" | sudo tee /etc/apt/sources.list.d/ookla.list
- 
Update your package lists: sudo apt update
- 
Install the Speedtest CLI: sudo apt install speedtest
Using yum (CentOS/RHEL/Fedora)
For those on a Red Hat-based system like CentOS or Fedora, you can use yum or dnf. Here’s the process:
- 
Create a new repository file: sudo nano /etc/yum.repos.d/ookla.repo
- 
Add the following content to the file: [ookla] name=Ookla Speedtest baseurl=https://ookla.bintray.com/centos/ gpgcheck=1 gpgkey=https://ookla.bintray.com/ookla_bintray.gpg.key enabled=1
- 
Save the file and exit. 
- 
Install the Speedtest CLI: sudo yum install speedtest # OR sudo dnf install speedtest
Manual Installation
If you prefer a manual approach or if the above methods don't work for you, you can download the Speedtest CLI directly from Ookla's website. Here’s how:
- 
Download the appropriate binary for your system: Visit the Ookla Speedtest CLI download page. 
- 
Extract the downloaded archive: tar -xzvf speedtest_linux-x86_64.tar.gz # Adjust the filename as needed
- 
Move the speedtestbinary to a directory in your PATH (e.g.,/usr/local/bin):sudo mv speedtest /usr/local/bin
- 
Make the binary executable: sudo chmod +x /usr/local/bin/speedtest
Running Speedtest
Alright, you've got the Speedtest CLI installed. Now, let's run some tests! Open your terminal and simply type:
speedtest
This will run a standard speed test against the nearest server. The output will show you your download speed, upload speed, and ping. It's that easy!
Understanding the Output
When you run the speedtest command, you'll see something like this:
Retrieving speedtest.net configuration...
Testing from Your ISP (Your IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Server Name (City, Country) [Distance]: Ping
Testing download speed................................................................................
Testing upload speed..................................................................................
Download: XX.XX Mbit/s
Upload: YY.YY Mbit/s
Here's a breakdown:
- Download: This is the speed at which you can receive data from the internet. It's measured in Megabits per second (Mbit/s).
- Upload: This is the speed at which you can send data to the internet. Also measured in Mbit/s.
- Ping: This is the latency, or the time it takes for a small data packet to travel from your computer to the server and back. It's measured in milliseconds (ms). Lower ping is better.
These three metrics give you a comprehensive overview of your internet connection's performance.
Advanced Usage
The Speedtest CLI has a few cool options that let you customize your tests. Let's check them out.
Specifying a Server
If you want to test against a specific server, you can use the --server option followed by the server ID. To get a list of available servers, run:
speedtest --list
This will display a list of servers with their IDs, names, and locations. Then, you can run a test against a specific server like this:
speedtest --server 1234 # Replace 1234 with the actual server ID
Getting Results in Different Formats
You can also get the results in different formats, such as JSON or CSV. This is useful for scripting and automation.
- 
JSON: speedtest --accept-license --format=json
- 
CSV: speedtest --accept-license --format=csv
The --accept-license flag is required to accept the Speedtest license agreement when using these formats.
Sharing Results
Want to share your results with others? You can use the --share option to generate a shareable image with your test results.
speedtest --share
This will upload your results to Speedtest.net and provide you with a URL to share.
Troubleshooting
Sometimes, things don't go as planned. Here are a few common issues and how to fix them.
Command Not Found
If you get a "command not found" error after installation, make sure the speedtest binary is in a directory that's included in your system's PATH. You can check your PATH by running:
echo $PATH
If the directory where you installed the speedtest binary isn't listed, you'll need to add it. You can do this by editing your ~/.bashrc or ~/.zshrc file and adding a line like this:
export PATH=$PATH:/path/to/speedtest
Replace /path/to/speedtest with the actual directory where the speedtest binary is located. Then, reload your shell configuration:
source ~/.bashrc # Or source ~/.zshrc
Slow Speeds
If you're getting unexpectedly slow speeds, there could be a few reasons. First, make sure no other devices on your network are consuming a lot of bandwidth. Streaming video, downloading large files, or running backups can all impact your internet speed. Also, try testing against different servers to see if the issue is with a particular server. Finally, make sure your network drivers are up to date.
Connection Errors
If you're getting connection errors, make sure your firewall isn't blocking the Speedtest CLI. You may need to create a rule to allow outbound connections on port 8080. Also, check your internet connection to make sure you're actually connected to the internet.
Conclusion
And there you have it! You're now equipped to use the Speedtest CLI on Linux like a pro. Whether you're troubleshooting network issues, monitoring your internet speed, or just satisfying your curiosity, the Speedtest CLI is a valuable tool to have in your arsenal. Happy testing, and may your speeds be ever in your favor! This guide should have given you all the information you need to get started.