Speedtest CLI On Linux: A Quick Guide

by Jhon Lennon 38 views

Hey guys! Ever wondered how to quickly check your internet speed directly from your Linux terminal? Well, you're in luck! The Speedtest CLI is a fantastic tool that lets you do just that. It's fast, efficient, and super handy for those times when you don't want to open a browser. Let's dive into how you can get it up and running on your Linux machine.

Installation

First things first, you need to get the Speedtest CLI installed. The process is straightforward, but it can vary slightly depending on your Linux distribution. Don't worry; I'll walk you through the most common methods.

Using Snap

If you're on a system that supports Snap packages (like Ubuntu), this is probably the easiest way to install Speedtest CLI. Snap is a package management system that makes installing and updating software a breeze. To install Speedtest CLI via Snap, just open your terminal and type the following command:

sudo snap install speedtest-cli

You might be prompted for your password, so go ahead and enter that. Once the installation is complete, you should be able to run the speedtest-cli command directly from your terminal. Snap packages are great because they handle dependencies for you, so you don't have to worry about missing libraries or conflicting software versions. It's a hassle-free way to get Speedtest CLI up and running.

Using apt (Debian/Ubuntu)

For those of you on Debian-based systems like Ubuntu, you can also use apt, the Advanced Package Tool, to install Speedtest CLI. However, it's not available in the default repositories, so you'll need to download the .deb package directly from the Speedtest website or a trusted source. Be careful where you download it from to avoid getting malicious software! Once you've downloaded the .deb package, navigate to the directory where you saved it in your terminal. Then, use the following command to install it:

sudo dpkg -i <package_name>.deb

Replace <package_name>.deb with the actual name of the downloaded file. After running this command, you might encounter dependency issues. If you do, just run the following command to resolve them:

sudo apt-get install -f

This command tells apt to fix any broken dependencies, ensuring that Speedtest CLI can run properly. Using apt gives you more control over the installation process, but it also requires a bit more manual work. Make sure you download the package from a reputable source to stay safe.

Manual Installation

If you prefer a more hands-on approach, or if the above methods don't work for you, you can install Speedtest CLI manually. This involves downloading the source code, compiling it, and then installing it. This method is a bit more involved, but it's a good way to learn more about how software is built.

  1. Download the source code: You can usually find the source code on the Speedtest website or a code repository like GitHub. Look for a link to download a .tar.gz or .zip archive.

  2. Extract the archive: Once you've downloaded the archive, extract it to a directory of your choice. You can use the tar command for .tar.gz files:

    tar -xzvf <archive_name>.tar.gz
    

    Replace <archive_name>.tar.gz with the actual name of the downloaded file.

  3. Navigate to the extracted directory: Use the cd command to navigate to the directory where you extracted the source code.

  4. Compile the code: You'll need a C++ compiler like g++ to compile the code. If you don't have it already, you can install it using your distribution's package manager. For example, on Debian/Ubuntu, you can use:

    sudo apt-get install g++
    

    Once you have a compiler, you can usually compile the code by running a make command:

    make
    
  5. Install the compiled binary: After compiling the code, you'll need to install the compiled binary to a directory in your system's PATH. This allows you to run the speedtest-cli command from anywhere in your terminal. You can usually do this with the following command:

    sudo make install
    

Manual installation gives you the most control over the process, but it also requires the most technical knowledge. Make sure you have a good understanding of compiling and installing software before attempting this method.

Running Speedtest CLI

Once you've installed Speedtest CLI, running it is super simple. Just open your terminal and type:

speedtest-cli

The tool will automatically detect the nearest Speedtest server and start testing your download and upload speeds. The output is clean and easy to read, showing you your ping, download speed, and upload speed. It's a great way to quickly get a snapshot of your internet performance.

Understanding the Output

The output from Speedtest CLI is pretty straightforward, but let's break it down:

  • Ping: This is the latency of your connection, measured in milliseconds (ms). It's the time it takes for a small packet of data to travel from your computer to the Speedtest server and back. Lower ping is better, especially for online gaming and real-time applications.
  • Download Speed: This is the rate at which data is being downloaded to your computer, measured in megabits per second (Mbps). It's a measure of how quickly you can download files, stream videos, and browse the web. Higher download speed is better.
  • Upload Speed: This is the rate at which data is being uploaded from your computer, measured in megabits per second (Mbps). It's a measure of how quickly you can upload files, send emails, and share content online. Higher upload speed is better.

Understanding these metrics is crucial for troubleshooting internet issues. If you're experiencing slow speeds, you can use Speedtest CLI to identify whether the problem is with your internet connection or with your device.

Advanced Options

Speedtest CLI also comes with a bunch of advanced options that let you customize the test. Here are a few of the most useful ones:

  • --server <server_id>: This option lets you specify a particular Speedtest server to use. You can find a list of server IDs by running speedtest-cli --list. Using a specific server can be useful if you want to test your connection to a particular location. It's also helpful for troubleshooting issues with specific servers.
  • --share: This option generates a shareable image of your test results. You can then share this image on social media or embed it in a website. Sharing your results is a great way to show off your internet speed or to compare your speed with others. It's also useful for reporting issues to your ISP.
  • --simple: This option outputs the results in a simplified format, making it easier to parse the output in scripts. The simple output is perfect for automating speed tests and collecting data over time. It's a great way to monitor your internet performance and identify trends.
  • --bytes: Shows the speed in bytes instead of bits. Useful for some calculations.
  • --no-upload: Only runs the download test. Useful if you suspect issues specific to download speeds.
  • --no-download: Only runs the upload test. Useful if you suspect issues specific to upload speeds.

To see a full list of options, just run speedtest-cli --help. Exploring the available options is a great way to get the most out of Speedtest CLI. Experiment with different options to see how they affect your results.

Troubleshooting

Sometimes, you might run into issues when using Speedtest CLI. Here are a few common problems and how to fix them:

  • speedtest-cli: command not found: This usually means that the Speedtest CLI executable is not in your system's PATH. Make sure that the directory where you installed Speedtest CLI is included in your PATH environment variable. Adding the directory to your PATH is essential for being able to run the command from anywhere. You can usually do this by editing your .bashrc or .zshrc file.
  • Slow speeds: If you're getting slow speeds, there could be several reasons. First, make sure that no other devices on your network are consuming a lot of bandwidth. Also, try running the test at different times of day to see if the speed varies. If you're still getting slow speeds, contact your ISP. Troubleshooting slow speeds can be tricky, but Speedtest CLI can help you narrow down the problem. Start by checking your network usage and then contact your ISP if necessary.
  • Connection errors: If you're getting connection errors, there could be a problem with your internet connection or with the Speedtest server. Try running the test again later or try specifying a different server using the --server option. Connection errors can be frustrating, but they're often temporary. Try again later or try a different server.

Conclusion

So, there you have it! The Speedtest CLI is a super useful tool for quickly checking your internet speed from your Linux terminal. It's easy to install, simple to use, and packed with advanced options. Whether you're troubleshooting internet issues or just curious about your connection speed, Speedtest CLI has you covered. Go ahead and give it a try, and let me know what you think! Mastering Speedtest CLI is a great way to take control of your internet experience. It's a valuable tool for anyone who wants to understand and optimize their network performance. I hope this guide was helpful, and happy speed testing, guys!