Speedtest CLI: Test Internet Speed On Linux Command Line
Hey guys! Ever wondered how to check your internet speed directly from your Linux terminal? Well, you're in the right place! In this article, we're diving deep into the Speedtest CLI, a command-line interface for testing your internet speed using Speedtest.net. It's super handy for those times when you're working on a server, troubleshooting network issues, or just prefer the terminal over a graphical interface. Let's get started!
What is Speedtest CLI?
The Speedtest CLI is the command-line version of the popular Speedtest.net service. Instead of opening a web browser and navigating to the Speedtest website, you can simply run a command in your terminal to get your download speed, upload speed, and ping. It's lightweight, fast, and provides accurate results. This tool is particularly useful for system administrators, developers, and anyone who spends a lot of time working in the command line. It eliminates the need to switch to a GUI, making it a seamless part of your workflow. Plus, it's scriptable, meaning you can automate speed tests and monitor your internet connection over time.
Why Use Speedtest CLI?
- Convenience: No need to open a browser. Just run a command in your terminal.
- Automation: You can script it to run regularly and log the results.
- Server Testing: Perfect for testing the internet speed on servers without a GUI.
- Lightweight: Minimal resource usage compared to a full browser.
- Accurate Results: Uses the same reliable Speedtest.net servers.
Installation
Alright, let's get this show on the road! Here’s how to install the Speedtest CLI on various Linux distributions.
Prerequisites
Before we start, make sure you have curl installed. If not, you can install it using your distribution's package manager. For example, on Debian/Ubuntu:
sudo apt update
sudo apt install curl
And on Fedora/CentOS/RHEL:
sudo dnf install curl
Installing Speedtest CLI
The easiest way to install Speedtest CLI is by downloading the pre-built binary. Here’s how:
- 
Download the Binary: First, download the appropriate binary for your system architecture. You can find the links on the official Speedtest CLI download page. For 64-bit Linux systems, use the following command: curl -o speedtest https://install.speedtest.net/app/cli/install.sh chmod +x speedtest sudo mv speedtest /usr/local/bin/speedtest
- 
Make it Executable: Make the downloaded file executable: chmod +x speedtest
- 
Move to a Directory in Your PATH: Move the executable to a directory in your system's PATH, such as /usr/local/bin/:
sudo mv speedtest /usr/local/bin/ ```
Verifying the Installation
To make sure everything is installed correctly, run:
speedtest --version
This should display the version number of the Speedtest CLI. If you see the version number, you're good to go!
Using Speedtest CLI
Now that you've installed the Speedtest CLI, let's see how to use it.
Basic Usage
The simplest way to use Speedtest CLI is to just run the speedtest command:
speedtest
This will run a speed test and display the results in your terminal. The output includes your download speed, upload speed, and ping. It will automatically select the best server based on your location.
Advanced Options
Speedtest CLI comes with several options that allow you to customize your speed tests. Here are some of the most useful ones:
- --server <server_id>: Specify a specific server to use for the test. You can find a list of server IDs using the- --listoption.
- --list: List available Speedtest.net servers.
- --ping: Only perform a ping test.
- --download: Only perform a download test.
- --upload: Only perform an upload test.
- --bytes: Display results in bytes instead of bits.
- --no-download: Do not perform a download test.
- --no-upload: Do not perform an upload test.
- --accept-license: Accept the license agreement. This is useful for scripting.
- --progress: Show the progress of the test.
Examples
- 
List Available Servers: 
speedtest --list ```
This command will display a list of available servers, along with their IDs and distances from your location.
- 
Specify a Server: 
speedtest --server 1234 ```
Replace `1234` with the ID of the server you want to use.
- 
Run a Ping Test Only: 
speedtest --ping ```
This command will only perform a ping test and display the results.
- 
Accept License and Run Test: 
speedtest --accept-license ```
This command accepts the license and runs the test.
Automating Speed Tests
One of the coolest things about Speedtest CLI is that you can automate speed tests using cron jobs or other scheduling tools. This is great for monitoring your internet connection over time.
Using Cron
Cron is a time-based job scheduler in Linux. To set up a cron job, you'll need to edit the crontab file.
- 
Open Crontab: Open the crontab file for editing using the following command: 
crontab -e ```
This will open the crontab file in a text editor. If it's your first time, you might be asked to choose an editor.
- 
Add a Cron Job: Add a line to the crontab file that specifies when and how often you want to run the speed test. For example, to run the speed test every hour and save the results to a file, you can use the following line: 0 * * * * speedtest --accept-license > /home/user/speedtest.txtThis will run the speedtestcommand every hour at the beginning of the hour and save the output to a file namedspeedtest.txtin your home directory. Remember to replace/home/user/speedtest.txtwith the actual path.
- 
Save and Exit: Save the crontab file and exit the text editor. The cron daemon will automatically pick up the changes. 
Analyzing the Results
After running the automated speed tests for a while, you can analyze the results to see how your internet connection performs over time. You can use tools like grep, awk, and sed to extract the relevant information from the log files and create graphs or charts.
Troubleshooting
Sometimes, things don't go as planned. Here are some common issues and how to fix them.
Command Not Found
If you get a