How to use the command speedtest (with examples)
The speedtest
command is the official command-line interface for testing internet bandwidth using https://speedtest.net
. It provides users with detailed information about their internet connection speed.
Use case 1: Run a speed test
Code:
speedtest
Motivation: This use case is helpful for users who want to quickly check their internet connection speed without specifying any additional parameters.
Explanation: Running the speedtest
command without any arguments will perform a speed test and display the results in a human-readable format.
Example output:
Testing download speed... 50.13 Mbps
Testing upload speed... 20.52 Mbps
Ping: 15 ms
Use case 2: Run a speed test and specify the unit of the output
Code:
speedtest --unit=auto-decimal-bits
Motivation: Some users may prefer to view the speed test results in a specific unit format that suits their needs.
Explanation: The --unit
argument allows users to specify the unit of the speed test output. In this example, auto-decimal-bits
is used to display the output in a decimal-based bit format.
Example output:
Testing download speed... 50123.00 bit/s
Testing upload speed... 20520.00 bit/s
Ping: 15 ms
Use case 3: Run a speed test and specify the output format
Code:
speedtest --format=csv
Motivation: Users may want to save the speed test results in a specific format to analyze or process the data further.
Explanation: The --format
argument is used to specify the output format of the speed test results. In this example, csv
is used to save the output in Comma-Separated Values (CSV) format.
Example output:
"Server ID","Sponsor","Server Name","Timestamp","Distance","Ping","Download","Upload","Share","IP Address"
"12345","Example ISP","Example Server","2022-01-01T00:00:00Z","50.00 km","15 ms","50.13 Mbps","20.52 Mbps","https://www.speedtest.net/result/1234567890","123.45.67.89"
Use case 4: Run a speed test and specify the number of decimal points to use
Code:
speedtest --precision=4
Motivation: Users who require more precise results may want to increase the number of decimal points in the speed test output.
Explanation: The --precision
argument allows users to specify the number of decimal points to display in the speed test results. In this example, 4
is used to display the output with four decimal points.
Example output:
Testing download speed... 50.1295 Mbps
Testing upload speed... 20.5178 Mbps
Ping: 15 ms
Use case 5: Run a speed test and print its progress
Code:
speedtest --progress=yes
Motivation: Users who want to monitor the progress of the speed test in real-time may find this use case beneficial.
Explanation: The --progress
argument is used to enable or disable the progress display during the speed test. Setting it to yes
will print the progress, while no
will hide it. This option is only available for the human-readable
and json
output formats.
Example output:
Testing download speed... 50.13 Mbps [==========] 100%
Testing upload speed... 20.52 Mbps [==========] 100%
Ping: 15 ms
Use case 6: List all speedtest.net servers, sorted by distance
Code:
speedtest --servers
Motivation: Users who want to view a list of available speedtest.net servers can use this command to get detailed information about them, including their distance.
Explanation: The --servers
argument is used to list all speedtest.net servers in the command-line interface. The servers are sorted by distance, allowing users to select a specific server for the speed test.
Example output:
ID Name Sponsor Distance
123 Example Server 1 Example ISP 50.00 km
456 Example Server 2 Example ISP 75.00 km
789 Example Server 3 Example ISP 100.00 km
Use case 7: Run a speed test to a specific speedtest.net server
Code:
speedtest --server-id=123
Motivation: Users who want to perform a speed test to a specific speedtest.net server can use this command by providing the server ID.
Explanation: The --server-id
argument is used to specify the server ID of the speedtest.net server to test against. In this example, the server with ID 123 is selected.
Example output:
Testing against server: Example Server 1 (123)
Testing download speed... 50.13 Mbps
Testing upload speed... 20.52 Mbps
Ping: 15 ms
Conclusion:
The speedtest
command provides a versatile solution for testing internet bandwidth. With various options to customize the output format, unit, decimal points, and server selection, users have full control over their speed test experience. It is a valuable tool for monitoring and troubleshooting internet connections.