How to Use the Command 'speedtest-cli' (with examples)

How to Use the Command 'speedtest-cli' (with examples)

The speedtest-cli is a command-line interface tool designed for testing internet bandwidth using servers hosted by Speedtest.net. It is a useful tool for those looking to measure their internet speed from a terminal environment without the need for a web browser. The tool can perform tests for download and upload speeds, and latency, and provides several options for customizing these tests. It is particularly helpful for programmers, network administrators, and tech enthusiasts who want to diagnose internet speed issues or optimize their network settings.

Run a speed test

Code:

speedtest-cli

Motivation:

Running a basic speed test is the most straightforward way to gauge your current internet speed. By executing this command, you can quickly obtain real-time metrics on your download and upload speeds, as well as ping time. This information is invaluable when aiming to confirm your ISP’s speed delivery or troubleshooting connectivity issues.

Explanation:

  • speedtest-cli: This is the command that initiates a speed test using the default settings of the Speedtest CLI. It connects to the optimal server (based on latency) and measures the download and upload speeds.

Example Output:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from ISP Name (Your IP)...
Hosted by Server Provider (Location) [Distance miles]: 20.123 ms
Download: 123.45 Mbit/s
Upload: 67.89 Mbit/s

Run a speed test and display values in bytes

Code:

speedtest-cli --bytes

Motivation:

Sometimes, it’s more practical to view internet speeds in terms of bytes rather than bits. Many users prefer this measurement because it more closely aligns with file sizes on their devices, providing a clearer understanding of how fast large files can be downloaded or uploaded.

Explanation:

  • --bytes: This argument modifies the unit of measurement, displaying speed results in bytes instead of the default bits. Since one byte equals eight bits, the results will numerically appear smaller but are more relatable to everyday file sizes.

Example Output:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from ISP Name (Your IP)...
Hosted by Server Provider (Location) [Distance miles]: 18.456 ms
Download: 15.43 MB/s
Upload: 8.49 MB/s

Run a speed test using HTTPS

Code:

speedtest-cli --secure

Motivation:

In today’s security-conscious environment, ensuring encrypted communication is vital. Running a speed test over HTTPS ensures that the data transmission involved in the speed test is secured, which is crucial for users who prioritize privacy, especially on untrusted networks.

Explanation:

  • --secure: This argument forces the speed test to use HTTPS for communication instead of the usual HTTP. This option enhances security by encrypting the data exchanged during the test.

Example Output:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from ISP Name (Your IP) using HTTPS...
Hosted by Server Provider (Location) [Distance miles]: 16.789 ms
Download: 130.12 Mbit/s
Upload: 70.45 Mbit/s

Run a speed test without performing download tests

Code:

speedtest-cli --no-download

Motivation:

Sometimes users need to focus solely on upload speeds, such as when troubleshooting high latency issues or optimizing upload bandwidth for cloud storage or streaming services. This command skips download testing, saving time and bandwidth if download metrics are not needed.

Explanation:

  • --no-download: This argument instructs the CLI to skip the download component of the speed test. The focus is solely on obtaining upload speeds and latency.

Example Output:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from ISP Name (Your IP)...
Hosted by Server Provider (Location) [Distance miles]: 17.456 ms
Upload: 68.23 Mbit/s

Run a speed test and generate an image of the results

Code:

speedtest-cli --share

Motivation:

Generating a sharable image of your speed test results is perfect for reporting or sharing your network speed data with customer support or on social media. This feature provides a convenient way to visually share your test results without additional formatting.

Explanation:

  • --share: This argument generates a unique URL to an image of your results. The image hosted on Speedtest.net can be easily shared or embedded in reports.

Example Output:

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from ISP Name (Your IP)...
Hosted by Server Provider (Location) [Distance miles]: 20.789 ms
Download: 121.34 Mbit/s
Upload: 65.89 Mbit/s
Share results: http://www.speedtest.net/result/example.png

List all Speedtest.net servers

Code:

speedtest-cli --list

Motivation:

Listing all available speed test servers is beneficial for users who wish to perform tests on specific servers. This is particularly useful for controlled testing environments where tests must be conducted consistently from specific locations.

Explanation:

  • --list: This argument provides a complete list of Speedtest.net servers, sorted by proximity to your current location. Users can utilize this list to understand their server options.

Example Output:

Retrieving speedtest.net configuration...
2785) Server Provider (City, Country) [Distance km]
2786) Another Provider (City, Country) [Distance km]
...

Run a speed test to a specific server

Code:

speedtest-cli --server server_id

Motivation:

Selecting a specific server ensures consistent test conditions and is crucial for users performing comparative analyses of network performance over time or across different regions.

Explanation:

  • --server server_id: This argument specifies which server to use for the speed test, replacing ‘server_id’ with the actual numeric ID from the server list obtained using the --list option.

Example Output:

Retrieving speedtest.net configuration...
Testing from ISP Name (Your IP)...
Hosted by Desired Server Provider (Location) [Distance miles]: 17.123 ms
Download: 118.88 Mbit/s
Upload: 66.45 Mbit/s

Run a speed test and display results as JSON

Code:

speedtest-cli --json

Motivation:

Exporting speed test results as JSON is highly useful for integration with other tools and scripts, analytics, and automated network monitoring. JSON format provides a structured data output that can be parsed programmatically, facilitating further processing or storage.

Explanation:

  • --json: This argument outputs the results of the speed test in JSON format, which can be easily used for data analysis or stored in a database.

Example Output:

{
    "download": 127885500.23,
    "upload": 66831400.47,
    "ping": 16.789,
    "server": {
        "url": "http://server.provider.url/speedtest/upload.php",
        "lat": "40.7128", 
        "lon": "-74.0060",
        "name": "City Name",
        "country": "Country",
        "cc": "CC",
        "sponsor": "Provider Name",
        "id": "12345",
        "host": "server.provider.url:8080",
        "d": 3.456,
        "latency": 16.789
    },
    "timestamp": "2023-10-07T12:34:56.789Z"
    "bytes_sent": 83990654,
    "bytes_received": 191739862,
    "share": "http://www.speedtest.net/result/example.png",
    "client": {
        "ip": "Your IP",
        "lat": "40.7128",
        "lon": "-74.0060",
        "isp": "ISP Name",
        "isprating": "3.7",
        "rating": "0",
        "ispdlavg": "0",
        "ispulavg": "0",
        "loggedin": "0",
        "country": "Country"
    }
}

Conclusion:

The speedtest-cli is a powerful and flexible command-line tool for anyone needing to assess internet connectivity. Whether you require a quick check of your bandwidth, a detailed JSON output for integration with other systems, or specific server testing for comparative studies, this tool caters to a wide range of user needs.

Related Posts

How to use the command 'openssl s_client' (with examples)

How to use the command 'openssl s_client' (with examples)

OpenSSL is a robust, full-featured open-source toolkit implemented mainly in C programming language.

Read More
How to Use the 'find' Command on Windows (with examples)

How to Use the 'find' Command on Windows (with examples)

The ‘find’ command is a powerful utility in Windows operating systems that allows users to search for specific strings within files or directories.

Read More
How to Use the Command 'ipconfig' (with Examples)

How to Use the Command 'ipconfig' (with Examples)

The ipconfig command is a powerful tool built into Microsoft Windows, used to display and manage the network configuration of your system.

Read More