Linux

How to check Internet Speed via Terminal

This tutorial will cover various tools you can use to test your internet speed from the terminal. This can be very useful when connected to a remote machine via SSH or just feeling lazy to open your browser 😊.
Captain Salem 4 min read
How to check Internet Speed via Terminal

Testing your internet speed can be a great source of information. For example, you can use it to gather the capabilities of your network hardware, test the effect of a network protocol such as OpenVPN on your network, etc. It is, therefore, an excellent tool for network troubleshooting.

Using Speedtest CLI

The Speediest-CLI is one of the most popular and powerful tools to test your internet speed from the terminal. It powers sites such as speedtest.net, which allows you to perform an internet speed test from your browser.

https://github.com/sivel/speedtest-cli

To install the speedtest-cli, run the apt command:

sudo apt-get install speedtest-cli

You can also run the tool as Β Python script. Install it with pip:

sudo pip3 install speedtest-cli

Or:

sudo easy_install speedtest-cli

Once installed, you can perform a speedtest from your terminal by running the command:

speedtest

The command should detect your network location and perform a speed test from the nearest server. An example output is provided in the block below:

Retrieving speedtest.net configuration...
Testing from Anonymous Networks (34.68.75.28)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Future Technologies (Omaha, NE) [12.44 km]: 27.316 ms
Testing download speed................................................................................
Download: 1509.54 Mbit/s
Testing upload speed........................................................................................
Upload: 576.02 Mbit/s

You should see your download and upload speeds in Megabits. If you do not wish to view all the test details including ping, you can run the command in simple mode:

speedtest --simple

Output:

Ping: 26.532 ms
Download: 1464.64 Mbit/s
Upload: 594.05 Mbit/s

Using the Fast CLI Utility

You are probably familiar with fast.com. A simple speed test service provided by Netflix. Luckily, it provides u CLI utility we can use to perform a speed test from the terminal.

The utility is based on Node.JS, hence, you may need to install Node and NPM on your system.

Install Node.js with the command:

curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

Finally, install fast-cli:

$ sudo npm install --global fast-cli

Once the installation is complete, you can perform a speed test with the command:

fast
	2000 Mbps ↓

The command should return the download speed for your connection.

To show the download and upload speed, run:

fast -u
	2000 Mbps ↓ / 1000 Mbps ↑

Using iPerf

There is one defect tool when it comes to network testing, including features such as transfer speed, network throttling, etc.

It is therefore a great tool when you need to test the speed of LAN connection.

Start by installing perf with the command:

sudo apt-get install iperf3

Once installed, open run the iperf server on machine you just installed the perf tool. The command is as provided:

iperf3 -s

This launches a server that listens for incoming connections from the client.

-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

In a machine connected to the same local network, run the command:

iperf3 -c <ip_address_to_server>

Enter the ip address of the iperf server. You can check the IP for your server with the command:

ip addr | grep -i inet.*brd

Example output:

inet 10.128.0.4/32 brd 10.128.0.4 scope global dynamic ens4

Locate the IP address and run the command as shown in the example below:

iperf3 -c 10.128.0.4

The command above will connect to the server and perform the tests. On the client side, you should see an output as shown:

Connecting to host 10.128.0.4, port 5201
[  5] local 10.128.0.4 port 47330 connected to 10.128.0.4 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  3.42 GBytes  29.4 Gbits/sec    0   3.18 MBytes       
[  5]   1.00-2.00   sec  3.56 GBytes  30.6 Gbits/sec    0   3.18 MBytes       
[  5]   2.00-3.00   sec  3.49 GBytes  30.0 Gbits/sec    0   3.18 MBytes       
[  5]   3.00-4.00   sec  3.49 GBytes  30.0 Gbits/sec    0   3.18 MBytes       
[  5]   4.00-5.00   sec  3.56 GBytes  30.6 Gbits/sec    0   3.18 MBytes       
[  5]   5.00-6.00   sec  3.50 GBytes  30.0 Gbits/sec    0   3.18 MBytes       
[  5]   6.00-7.00   sec  3.52 GBytes  30.2 Gbits/sec    0   3.18 MBytes       
[  5]   7.00-8.00   sec  3.22 GBytes  27.6 Gbits/sec    0   3.18 MBytes       
[  5]   8.00-9.00   sec  3.34 GBytes  28.7 Gbits/sec    0   3.18 MBytes       
[  5]   9.00-10.00  sec  3.50 GBytes  30.0 Gbits/sec    0   3.18 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  34.6 GBytes  29.7 Gbits/sec    0             sender
[  5]   0.00-10.04  sec  34.6 GBytes  29.6 Gbits/sec                  receiver

iperf Done.

The above displays the transfer speeds for your local network.

On the server side, you should see an output as provided below:

Accepted connection from 10.128.0.4, port 47324
[  5] local 10.128.0.4 port 5201 connected to 10.128.0.4 port 47330
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  3.27 GBytes  28.1 Gbits/sec                  
----- output missing ----------------------------             
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.04  sec  34.6 GBytes  29.6 Gbits/sec                  receiver

End!

End

Congrats! You have discovered three main methods you can use to perform an internet speed from your terminal session.

Let us know which tool you found most useful and comfortable to use down in the comments.

If you enjoy our content, please consider buying us a coffee to support our work:

Share
Comments
More from GeekBits

Join us at GeekBits

Join our members and get a currated list of awesome articles each month.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to GeekBits.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.