Speedtest CLI: How To Use The Command Line App
Hey guys! Today, we're diving deep into the Speedtest CLI, a nifty command-line tool that lets you check your internet speed directly from your terminal. If you're a developer, a system administrator, or just a tech enthusiast who loves the command line, this guide is for you. We'll cover everything from installation to advanced usage, ensuring you get the most out of this powerful tool. So, buckle up and let's get started!
What is Speedtest CLI?
Speedtest CLI is the command-line interface for the popular Speedtest by Ookla service. Instead of opening a web browser and navigating to Speedtest.net, you can simply run a command in your terminal to get your internet speed. This is particularly useful for automated testing, server monitoring, and situations where a graphical interface isn't available.
The Speedtest CLI tool is designed to be lightweight and efficient, providing accurate results without hogging system resources. It's compatible with various operating systems, including Windows, macOS, and Linux, making it a versatile tool for anyone needing to monitor network performance. The key benefit of using Speedtest CLI is its ability to provide consistent and reliable results, which is crucial for troubleshooting network issues or ensuring that your internet service provider is delivering the promised speeds.
Furthermore, the command-line interface allows for scripting and automation, enabling you to schedule regular speed tests and log the results. This can be incredibly valuable for identifying patterns in your network performance over time. For example, you might notice that your internet speed consistently drops during peak hours, indicating a potential issue with your ISP's infrastructure. By automating these tests, you can gather data without manual intervention, making it easier to diagnose and address network problems.
Another advantage of Speedtest CLI is its ability to bypass browser-related issues that can sometimes affect the accuracy of web-based speed tests. Factors such as browser extensions, cached data, and background processes can all skew the results. By using a dedicated command-line tool, you can minimize these variables and obtain a more accurate representation of your actual internet speed. This is especially important for ัะตั , who rely on consistent and reliable network performance for work or other critical activities.
In addition to basic speed testing, Speedtest CLI offers a range of advanced features, such as the ability to select specific test servers, customize the test duration, and specify the number of parallel connections. These options allow you to fine-tune the test to match your specific needs and environment. For instance, if you're testing the performance of a server in a particular region, you can specify a server in that region to get a more accurate measurement of latency and throughput. Similarly, if you're testing a high-bandwidth connection, you can increase the number of parallel connections to fully saturate the link.
Installation
Before we dive into using Speedtest CLI, let's get it installed on your system. The installation process varies slightly depending on your operating system, but don't worry, I'll walk you through each one.
Windows
- Download the Executable: Go to the official Speedtest CLI download page and grab the Windows executable file.
- Extract the File: Extract the contents of the downloaded ZIP file to a location of your choice, such as C:\Speedtest.
- Add to PATH: To make the speedtest.execommand accessible from any command prompt window, you need to add the directory containing the executable to your system's PATH environment variable.- Search for "Environment Variables" in the Start Menu and click on "Edit the system environment variables."
- Click on "Environment Variables..." button.
- In the "System variables" section, find the Pathvariable, select it, and click "Edit..."
- Click "New" and add the path to the directory where you extracted the Speedtest CLI executable (e.g., C:\Speedtest).
- Click "OK" on all the windows to save the changes.
 
- Verify Installation: Open a new command prompt window and type speedtest -v. If Speedtest CLI is installed correctly, it will display the version number.
macOS
There are a couple of ways to install Speedtest CLI on macOS:
- Using Homebrew: If you have Homebrew installed, this is the easiest method.
- Open Terminal.
- Type brew install speedtest-cliand press Enter.
- Wait for the installation to complete.
- Verify the installation by typing speedtest -vin the Terminal.
 
- Manual Installation:
- Download the macOS binary from the official Speedtest CLI download page.
- Extract the downloaded ZIP file to a directory of your choice (e.g., /usr/local/bin).
- Open Terminal.
- Make the executable file executable by running the command chmod +x /usr/local/bin/speedtest.
- Verify the installation by typing speedtest -vin the Terminal.
 
Linux
Similarly to macOS, you can install Speedtest CLI on Linux using a package manager or manually.
- Using apt (Debian/Ubuntu):
- Open Terminal.
- Update the package list by running sudo apt update.
- Install Speedtest CLI by running sudo apt install speedtest-cli.
- Verify the installation by typing speedtest -vin the Terminal.
 
- Using yum (CentOS/RHEL/Fedora):
- Open Terminal.
- Install Speedtest CLI by running sudo yum install speedtest-cli.
- Verify the installation by typing speedtest -vin the Terminal.
 
- Manual Installation:
- Download the Linux binary from the official Speedtest CLI download page.
- Extract the downloaded ZIP file to a directory of your choice (e.g., /usr/local/bin).
- Open Terminal.
- Make the executable file executable by running the command chmod +x /usr/local/bin/speedtest.
- Verify the installation by typing speedtest -vin the Terminal.
 
Once you've completed the installation steps for your operating system, you're ready to start using Speedtest CLI to test your internet speed. Make sure to verify the installation by running speedtest -v to confirm that the tool is working correctly. This will help you avoid any issues later on when you're trying to run speed tests.
Basic Usage
Now that you have Speedtest CLI installed, let's look at some basic commands to get you started. The simplest way to use Speedtest CLI is to just type speedtest in your terminal and press Enter. This will run a standard speed test and display the results in your terminal.
Running a Speed Test
To perform a basic speed test, open your terminal or command prompt and type:
speedtest
Press Enter, and Speedtest CLI will automatically:
- Find the nearest Speedtest server.
- Test your download speed.
- Test your upload speed.
- Display the results, including ping, download speed, and upload speed.
The output will look something like this:
Retrieving speedtest.net configuration...
Testing from Your ISP (Your IP Address)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Your Server Name (Your Server Location) [X.XX km]: XX.XX ms
Testing download speed........................................
Testing upload speed..................................................
Download: XX.XX Mbit/s
Upload: XX.XX Mbit/s
This is the most straightforward way to use Speedtest CLI, providing you with a quick overview of your current internet speed. It's perfect for ัะตั , who just want to check their speed without any additional options or configurations. However, Speedtest CLI offers many advanced features that allow you to customize the test to your specific needs.
Understanding the Results
The results displayed by Speedtest CLI include several key metrics:
- Ping: The latency, or round-trip time, between your computer and the test server. Lower ping times are better, indicating a more responsive connection.
- Download Speed: The rate at which data can be downloaded from the internet to your computer. Measured in megabits per second (Mbps), higher download speeds are better for streaming, downloading files, and browsing the web.
- Upload Speed: The rate at which data can be uploaded from your computer to the internet. Also measured in Mbps, higher upload speeds are better for video conferencing, uploading files, and sending emails.
Understanding these metrics is crucial for assessing the quality of your internet connection. For example, if you're experiencing slow loading times while browsing the web, a low download speed might be the culprit. Similarly, if you're having trouble with video calls, a low upload speed could be the issue. By monitoring these metrics over time, you can identify patterns and potential problems with your network.
Additional Options
Speedtest CLI also supports several command-line options that allow you to customize the test. Here are a few useful options:
- -s, --server <SERVER_ID>: Specify a server ID to use for the test. You can find a list of server IDs using the- --listoption.
- --list: Display a list of available Speedtest servers.
- --bytes: Display results in bytes instead of bits.
- --share: Generate and display a shareable URL of the test result.
- --simple: Suppress verbose output and only show ping, download, and upload speeds.
Using these options, you can tailor the test to your specific needs. For example, if you want to test your connection to a specific server, you can use the --server option. If you prefer to see the results in bytes instead of bits, you can use the --bytes option. And if you want to share your results with others, you can use the --share option.
Advanced Usage
Now that you're comfortable with the basics, let's explore some advanced features of Speedtest CLI. These features allow you to fine-tune the test to your specific needs and gain more detailed insights into your network performance.
Selecting a Specific Server
Sometimes, you might want to test your connection to a specific server. This can be useful for testing the performance of a server in a particular region or for comparing the performance of different servers. To select a specific server, you first need to find its ID using the --list option:
speedtest --list
This will display a list of available Speedtest servers, along with their IDs, names, and locations. Once you have the ID of the server you want to use, you can specify it using the -s or --server option:
speedtest -s <SERVER_ID>
Replace <SERVER_ID> with the actual ID of the server. For example:
speedtest -s 1234
This will run a speed test against the server with ID 1234. This can be particularly useful for those, who need to test their connection to specific servers for work or other purposes. By selecting a specific server, you can ensure that the test is relevant to your specific needs.
Displaying Results in Bytes
By default, Speedtest CLI displays the results in megabits per second (Mbps). However, you might prefer to see the results in bytes per second (Bps). To display the results in bytes, use the --bytes option:
speedtest --bytes
This will change the output to display the download and upload speeds in bytes per second. This can be useful for those, who are more familiar with bytes as a unit of data transfer. It's a simple change, but it can make the results easier to understand for some users.
Sharing Your Results
If you want to share your speed test results with others, you can use the --share option. This will generate a shareable URL that you can send to friends, colleagues, or your ISP:
speedtest --share
After running the test, Speedtest CLI will display a URL that you can copy and paste into an email, message, or social media post. When someone clicks on the URL, they will see a summary of your test results, including ping, download speed, and upload speed. This is a convenient way to share your results without having to manually copy and paste the numbers.
Using Simple Output
If you want to suppress the verbose output and only see the ping, download speed, and upload speed, you can use the --simple option:
speedtest --simple
This will simplify the output to only show the key metrics, making it easier to quickly glance at the results. This is perfect for ัะตั , who want a no-frills speed test without all the extra information. It's a great way to get a quick overview of your internet speed without having to wade through a lot of text.
Automation and Scripting
One of the most powerful features of Speedtest CLI is its ability to be automated and scripted. This allows you to schedule regular speed tests and log the results, which can be incredibly valuable for monitoring your network performance over time.
Creating a Simple Script
To create a simple script that runs a speed test and logs the results, you can use a text editor to create a new file with a .sh extension (for Linux and macOS) or a .bat extension (for Windows). Here's an example of a simple script for Linux and macOS:
#!/bin/bash
DATE=$(date +"%Y-%m-%d %H:%M:%S")
PING=$(speedtest --simple | grep Ping | awk '{print $2}')
DOWNLOAD=$(speedtest --simple | grep Download | awk '{print $2}')
UPLOAD=$(speedtest --simple | grep Upload | awk '{print $2}')
echo "$DATE, $PING, $DOWNLOAD, $UPLOAD" >> speedtest.log
And here's an example of a simple script for Windows:
@echo off
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
for /f "tokens=1-2 delims=: " %%a in ('time /t') do (set mytime=%%a:%%b)
echo %mydate% %mytime%, >> speedtest.log
speedtest --simple >> speedtest.log
These scripts will run a speed test and append the results to a file called speedtest.log. You can then use a task scheduler (such as cron on Linux and macOS or Task Scheduler on Windows) to schedule the script to run at regular intervals.
Scheduling the Script
- 
Linux/macOS (using cron): - Open Terminal.
- Type crontab -eand press Enter.
- Add a line to the crontab file that specifies when to run the script. For example, to run the script every hour, add the following line:
 0 * * * * /path/to/your/script.sh
- 
Windows (using Task Scheduler): - Open Task Scheduler.
- Click "Create Basic Task..." in the right pane.
- Follow the prompts to create a new task that runs the script at regular intervals.
 
By scheduling the script to run automatically, you can collect data on your network performance over time without having to manually run the speed test. This can be incredibly valuable for identifying patterns and potential problems with your network.
Troubleshooting
Even with a straightforward tool like Speedtest CLI, you might encounter some issues. Here are a few common problems and how to solve them:
- "speedtest: command not found": This usually means that the Speedtest CLI executable is not in your system's PATH. Double-check that you've added the directory containing the executable to your PATH environment variable.
- Inaccurate Results: If you're getting results that seem too high or too low, try selecting a specific server using the -soption. Also, make sure that no other programs are using your internet connection while the test is running.
- Connection Errors: If you're getting connection errors, make sure that your internet connection is working properly. You can also try disabling your firewall or antivirus software temporarily to see if that's causing the problem.
By following these troubleshooting tips, you can resolve most of the common issues that you might encounter while using Speedtest CLI. If you're still having problems, consult the official documentation or seek help from online forums or communities.
Conclusion
Speedtest CLI is a powerful tool for checking your internet speed directly from the command line. Whether you're a developer, a system administrator, or just a tech enthusiast, Speedtest CLI can help you monitor your network performance and troubleshoot issues. By following this guide, you should now have a solid understanding of how to install, use, and automate Speedtest CLI. So go ahead, give it a try, and see what your internet speed is really like!