Speedtest CLI On Linux: A Quick Guide

by Jhon Lennon 38 views

Hey everyone! Ever wondered how to quickly check your internet speed directly from your Linux terminal? Well, you're in the right place! We're diving into how to use the Speedtest CLI (Command Line Interface) on Linux. This is super handy for getting instant speed test results without needing to open a browser. Let's get started!

What is Speedtest CLI?

The Speedtest CLI is a command-line tool provided by Speedtest.net. Instead of visiting their website, you can simply run a command in your terminal to measure your internet speed. It's lightweight, fast, and gives you all the essential metrics like download speed, upload speed, ping, and jitter. This is incredibly useful for system admins, developers, or anyone who prefers using the terminal over a graphical interface.

Why use Speedtest CLI, you ask? First off, it's efficient. No need to load up a browser and navigate through ads and other distractions. Secondly, it's scriptable. You can easily integrate it into scripts to monitor your internet speed over time. Thirdly, it's consistent. The results are generally more reliable because it eliminates the overhead of a web browser. Plus, it’s really cool to see your internet speed pop up in the terminal!

Moreover, the Speedtest CLI offers a level of automation that the web interface simply can't match. Imagine setting up a cron job to run a speed test every hour and log the results. This can be invaluable for diagnosing intermittent network issues or verifying that your ISP is delivering the speeds you're paying for. The CLI tool also allows for more precise control over the testing parameters. For example, you can specify a particular server to test against, which can be useful for troubleshooting connectivity issues with specific services or regions. Beyond basic speed testing, the Speedtest CLI provides additional features such as the ability to view your external IP address and the server list available for testing. These features, combined with its ease of use and scriptability, make the Speedtest CLI a powerful tool for anyone who needs to monitor and manage their network performance on Linux.

Installation

Step 1: Download the Speedtest CLI

First, you need to download the Speedtest CLI. You can grab the appropriate version for your Linux distribution from the official Speedtest CLI download page. Usually, you'll find .deb packages for Debian/Ubuntu-based systems and .rpm packages for Fedora/CentOS/RHEL-based systems. Alternatively, there might be a generic Linux binary available.

For example, if you're on a 64-bit Debian-based system, you might use wget to download the .deb package:

wget https://install.speedtest.net/app/cli/install.deb

Step 2: Install the Package

Once you've downloaded the package, you need to install it. For .deb packages, you can use dpkg or apt.

Using dpkg:

sudo dpkg -i install.deb
sudo apt-get install -f # Resolve any dependencies

Using apt:

sudo apt install ./install.deb

For .rpm packages, you can use rpm or yum / dnf.

Using rpm:

sudo rpm -i install.rpm

Using yum:

sudo yum install install.rpm

Using dnf:

sudo dnf install install.rpm

Step 3: Verify the Installation

After the installation is complete, verify that Speedtest CLI is correctly installed by running:

speedtest --version

This should display the version number of the Speedtest CLI. If you see the version, congrats! You're all set.

Installing the Speedtest CLI may occasionally present some challenges, particularly with dependency resolution. For example, if you encounter errors related to missing dependencies during the installation process, you may need to manually install those dependencies using your distribution's package manager. On Debian-based systems, the command sudo apt-get install -f is often helpful in resolving these issues automatically. Similarly, on RPM-based systems, sudo yum install or sudo dnf install can be used to install any missing dependencies. It's also important to ensure that your system is up-to-date before attempting to install the Speedtest CLI. Running sudo apt update && sudo apt upgrade on Debian-based systems or sudo yum update or sudo dnf upgrade on RPM-based systems can help prevent conflicts and ensure a smooth installation process. In rare cases, you may need to manually download and install specific dependency packages if they are not available in the standard repositories. However, this should only be necessary as a last resort, and you should always exercise caution when installing packages from untrusted sources.

How to Use Speedtest CLI

Using Speedtest CLI is pretty straightforward. Here are some basic commands to get you started.

Basic Speed Test

To run a simple speed test, just type:

speedtest

This will run a test against the nearest Speedtest server and display your download speed, upload speed, ping, and jitter.

Specifying a Server

If you want to test against a specific server, you first need to find its ID. List the available servers with:

speedtest --list

This command shows a list of servers with their IDs, names, and distances from your location. Once you have the ID, use the following command to test against that server:

speedtest --server <server_id>

Replace <server_id> with the actual server ID.

Getting Shareable Results

To get a shareable URL of your test result, use the --share option:

speedtest --share

This will run the test and provide a URL that you can share with others. It’s super useful when you need to show your internet speed results.

Saving Results to a File

Sometimes, you might want to save the test results to a file for later analysis. You can do this by redirecting the output to a file:

speedtest > results.txt

This will save the output to a file named results.txt.

Displaying Results in CSV Format

For easier parsing, especially in scripts, you can display the results in CSV (Comma Separated Values) format:

speedtest --csv

This format is great for importing into spreadsheets or other data analysis tools.

Understanding the Results

When you run a speed test, you'll see several key metrics:

  • Download Speed: The rate at which data is transferred from the server to your computer (measured in Mbps).
  • Upload Speed: The rate at which data is transferred from your computer to the server (measured in Mbps).
  • Ping: The latency or delay in the network connection (measured in ms). Lower ping is better.
  • Jitter: The variation in ping over time (measured in ms). Lower jitter is better.

Understanding these metrics helps you assess the quality of your internet connection. High download and upload speeds are essential for streaming, downloading, and video conferencing. Low ping is crucial for online gaming and real-time applications. Low jitter ensures a stable connection.

To further refine your use of the Speedtest CLI, consider exploring some of its advanced options. For instance, you can specify the interface to use for the test with the --interface option, which can be useful on systems with multiple network interfaces. You can also adjust the timeout settings with the --timeout option to accommodate slower connections or unreliable servers. Additionally, the --accept-license option allows you to bypass the license agreement prompt, making the tool even easier to use in automated scripts. By experimenting with these and other advanced options, you can tailor the Speedtest CLI to your specific needs and gain a more comprehensive understanding of your network performance.

Advanced Options

Speedtest CLI comes with several advanced options that can help you customize your tests.

Accepting the License

To accept the license agreement automatically (useful in scripts), use:

speedtest --accept-license

Getting Help

To see all available options, use the help command:

speedtest --help

This will display a list of all available options and their descriptions. It’s a great way to discover new features and ways to customize your speed tests.

Ignoring Configuration

To ignore the saved configuration, use:

speedtest --ignore-config

Single Connection Mode

To use a single connection for testing, use:

speedtest --single

This can be useful for troubleshooting or testing connections that don't support multiple streams.

Exploring the advanced options of the Speedtest CLI can significantly enhance your ability to diagnose and optimize your network performance. For example, the --server-id option allows you to target specific servers for testing, which can be useful for troubleshooting connectivity issues with particular services or regions. The --bytes option displays the transfer rates in bytes instead of bits, providing a different perspective on your network speed. Additionally, the --no-upload and --no-download options enable you to test only the download or upload speed, respectively, which can be helpful for isolating specific network issues. By mastering these advanced options, you can gain a more granular understanding of your network behavior and fine-tune your testing methodology to meet your specific requirements. Furthermore, leveraging these options in automated scripts can provide valuable insights into your network's performance over time, allowing you to identify trends and proactively address potential problems before they impact your users.

Troubleshooting

Command Not Found

If you get a “command not found” error after installation, make sure that the Speedtest CLI binary is in your system’s PATH. You can add it to your PATH by adding the directory containing the binary to your ~/.bashrc or ~/.zshrc file.

Permission Issues

If you encounter permission issues, make sure that the Speedtest CLI binary is executable. You can change the permissions using:

chmod +x /usr/local/bin/speedtest

Replace /usr/local/bin/speedtest with the actual path to the binary.

Connection Errors

If you’re getting connection errors, ensure that your firewall isn’t blocking the Speedtest CLI. Also, check your internet connection and try again.

Inaccurate Results

If you find that the results are consistently inaccurate, try testing against different servers using the --server option. Some servers may be more reliable than others.

When troubleshooting issues with the Speedtest CLI, it's important to consider the potential impact of other applications and processes running on your system. For example, bandwidth-intensive applications such as streaming services, file downloads, or online games can significantly affect the accuracy of your speed test results. To minimize these effects, it's recommended to close any unnecessary applications before running the Speedtest CLI. Additionally, ensure that your system's network drivers are up-to-date, as outdated drivers can sometimes cause performance issues. If you're still experiencing problems, try restarting your modem and router to refresh your network connection. Finally, consider testing your internet speed at different times of the day, as network congestion can vary depending on the time of day and the number of users accessing the internet in your area.

Conclusion

So there you have it! Using Speedtest CLI on Linux is a quick and efficient way to check your internet speed directly from the terminal. It’s perfect for automation, scripting, and getting reliable results without the hassle of a web browser. Give it a try and see how fast your internet really is! Happy testing, folks!