Easy Steps To Check Internet Speed in Linux Terminal
In this guide, we aim to demonstrate how to Test or Check Internet Speed in Linux Terminal. By leveraging Linux tools, you can effortlessly assess your network data speed directly from the command line. This tutorial will guide you through using the speedtest-cli
and ping
commands to Check Internet Speed in Linux Terminal.
To effectively Check Internet Speed in Linux Terminal, you’ll need access to your server, either as a root user or a non-root user with sudo privileges. If you require assistance with initial server setup, you can find helpful guides on the Orcacore website.
Now, let’s proceed with the steps to test your network speed on Linux.
Step 1 – Check Internet Speed From Linux Command Line with speedtest-cli
The speedtest-cli
is a powerful Python tool designed for testing internet speeds on Linux. It allows you to measure your internet’s upload and download speeds, as well as ping latency.
To use this tool, you must first install it on your Linux distribution. Fortunately, it’s available in most Linux distributions, making installation via your package manager straightforward. Alternatively, you can download the installer to ensure you have the latest speedtest-cli
packages.
Install speedtest-cli on Debian / Ubuntu Linux
To install speedtest-cli
on Debian or Ubuntu Linux distributions, use the following commands:
# sudo apt update
# sudo apt install speedtest-cli -y
If you prefer installing the packages using the installer script, you can download the speed test installer from the terminal using the following curl
command:
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
Then, proceed to install speedtest-cli
with:
sudo apt install speedtest
Install speedtest-cli on Centos / RHEL / AlmaLinux / Rocky Linux
On CentOS and RHEL-based Linux distributions, you can install speedtest-cli
using the following commands:
# sudo yum install speedtest-cli -y #centos7-rhel7
# sudo dnf install speedtest-cli -y #centos8-rhel8-rhel9
Note: speedtest-cli
is typically available under the EPEL repository on CentOS and RHEL-based systems. If you haven’t already, you’ll need to install the EPEL repository before installing speedtest-cli
:
# sudo yum install epel-release
#sudo dnf install epel-release
Alternatively, you can use the installer script with these commands:
# curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
# sudo dnf install speedtest
Test Network Speed with speedtest-cli
With speedtest-cli
installed, you can perform a simple speed test using the following command in your Linux terminal:
Note: This command is for installations using the default repository.
speedtest-cli --simple
After executing the command, wait for the results. The output will display your upload and download speeds, along with ping latency.
ping: 25.123 ms
download: 85.45 Mbit/s
upload: 92.78 Mbit/s
For more detailed information about your network, run the speedtest-cli
command without any options:
speedtest-cli
This will provide comprehensive network information during and after the speed test, including your IP address, test location, and more.
To explore additional options and functionalities, use the help command:
speedtest-cli -h
If you installed the packages using the installer script, you can run the internet speed test from the terminal with the command:
speedtest
You’ll be prompted to accept the license agreement by pressing Y.
The output will provide a URL that allows you to view your results in a web browser.
You can also use the help command for the installer script version to get more information:
speedtest -h
Step 2 – Check Internet Speed From Linux Command Line with ping
Another method to assess your network speed is by using the ping
command. This command allows you to test the latency (speed between two computers) against your router or any server on the internet.
The ping
command is typically pre-installed on most Linux distributions. You can easily check your server’s internet speed by using the command below:
ping <your-ip-address>
You can also test your network speed against a website, for example:
ping google.com
That’s it! You’re done.
Conclusion
If you prefer to Check Internet Speed in Linux Terminal from the command line, the ping
and speedtest-cli
commands provide convenient ways to test your network speed directly in the Linux terminal.
Hope you found this guide helpful!
Alternative Methods to Check Internet Speed in Linux Terminal
While speedtest-cli
and ping
are excellent tools for checking internet speed from the Linux terminal, let’s explore two alternative approaches that can provide complementary insights into your network performance.
1. Using mtr
(Matt’s TraceRoute)
mtr
combines the functionality of ping
and traceroute
into a single, continuously updating display. This allows you to not only measure latency to a destination but also identify potential bottlenecks along the network path. It provides a real-time view of packet loss and response times at each hop, making it invaluable for diagnosing connectivity issues.
Explanation:
mtr
sends a sequence of ICMP (ping) packets to the target host.- For each packet, it increases the Time To Live (TTL) value, causing each router along the path to respond with an ICMP Time Exceeded message.
mtr
analyzes these responses to display the hostname, IP address, packet loss, and round-trip time for each hop.
Installation:
On Debian/Ubuntu:
sudo apt update
sudo apt install mtr
On CentOS/RHEL:
sudo yum install mtr
Usage and Code Example:
To use mtr
, simply run the command followed by the hostname or IP address you want to test:
mtr google.com
This will display a continuously updating report in your terminal. You can press q
to quit. The report shows each hop, along with its packet loss percentage, average ping time, and other relevant data. This is invaluable in diagnosing if a specific router along the path is causing slow speeds.
The output will look similar to this (though values will vary):
HOST: your_hostname Loss% Snt Last Avg Best Wrst StDev
1.|-- your_router 0.0% 10 0.5 0.6 0.5 0.8 0.1
2.|-- 192.168.1.1 0.0% 10 5.2 5.3 5.1 5.5 0.1
3.|-- some.isp.router 0.0% 10 8.7 9.0 8.6 10.1 0.4
4.|-- google.com 0.0% 10 15.3 15.5 15.2 15.8 0.2
This gives you a breakdown of the latency and packet loss at each hop, allowing you to pinpoint where the slowdown is occurring. Checking Internet Speed in Linux Terminal can be improved with this tool.
2. Using iperf3
for Bandwidth Measurement
While speedtest-cli
provides a convenient overall speed test, iperf3
offers a more controlled and precise way to measure bandwidth between two points on a network. It is particularly useful for testing the actual throughput achievable between two devices, independent of external internet factors. This is especially relevant for testing network performance between servers or within a local network.
Explanation:
iperf3
operates in a client-server model. One machine runs in server mode, listening for connections, while the other runs in client mode, initiating the connection and sending data.- The client sends data to the server for a specified duration, and both the client and server report the amount of data transferred and the measured bandwidth.
Installation:
On Debian/Ubuntu:
sudo apt update
sudo apt install iperf3
On CentOS/RHEL:
sudo yum install iperf3
Usage and Code Example:
First, on one machine (the server), start iperf3
in server mode:
iperf3 -s
This will listen on the default port (5201).
Then, on another machine (the client), connect to the server and run the bandwidth test:
iperf3 -c <server_ip_address>
Replace <server_ip_address>
with the IP address of the machine running in server mode. The client will connect to the server, send data for a default duration (usually 10 seconds), and then display the results, including the bandwidth achieved in Mbit/s.
Example Output:
[ ID] Interval Transfer Bandwidth Retr
[ 5] 0.00-10.00 sec 1.10 GBytes 942 Mbits/sec 0 sender
[ 5] 0.00-10.00 sec 1.10 GBytes 942 Mbits/sec 0 receiver
This output shows the bandwidth achieved between the client and server, providing a precise measurement of network throughput. Checking Internet Speed in Linux Terminal can be useful for local testing, but iperf3
is more accurate.
These alternative methods, mtr
and iperf3
, offer different perspectives on network performance compared to speedtest-cli
and ping
. mtr
helps diagnose network path issues, while iperf3
provides a precise bandwidth measurement between two specific points. Combining these tools provides a more comprehensive understanding of your network’s capabilities.