Speedtest from the command line interface (without installing software)

Performing an internet speedtest is an interesting way to measure how fast your internet connection is. It may give you insights into your internet connection quality, or you may want to know if you get what you pay for. I wrote my own internet speedtest, but a more popular alternative is speedtest.net.

However, you may find yourself in a situation where you want to measure your connection from a device without an internet browser. For example, a Raspberry Pi computer. In other words: performing a speedtest from SSH (via the command line interface – cli).

Command-line speedtest (without installing software)

If you are looking for the most simple way to measure the internet connection speed via a speedtest, it is via the wget command.

Perform a speedtest of a 100MB file from the command line:

wget -O /dev/null https://dl.vanhoutte.be/cdn/100MB.zip

What is happening here: wget is a command to get a file from somewhere on the intranet or internet. The -O parameter will indicate the output will be displayed. Then we define where to download it: in our case, we download it to /dev/null which is basically writing in the void (it will not need to be deleted afterwards by you). Lastly, we define what we will download. In this case, it is a 100MB file from my server.

Download a 1GB file:

wget -O /dev/null https://dl.vanhoutte.be/cdn/1GB.bin

The limitation of this method is that only the download speed will be measured, not the upload.

The advantage is that it is merely a command: no installation required.

Example output:

VANHOUTTE

[email protected]:~ $ wget -O /dev/null https://dl.vanhoutte.be/cdn/100MB.zip
--2021-01-26 15:32:11--  https://dl.vanhoutte.be/cdn/100MB.zip
Resolving dl.vanhoutte.be (dl.vanhoutte.be)... 2606:4700:3037::ac43:8a80, 2606:4700:3031::6815:40fd, 104.21.64.253, ...
Connecting to dl.vanhoutte.be (dl.vanhoutte.be)|2606:4700:3037::ac43:8a80|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/zip]
Saving to: '/dev/null'
/dev/null           100%[===================>] 100.00M  6.60MB/s    in 15s     
2021-01-26 15:32:26 (6.86 MB/s) - '/dev/null' saved [104857600/104857600]

Command-line speedtest (by installing the speedtest-cli software)

A second option you have is by installing a small piece of software which was created with the specific goal of measuring your upload and download speed. Speedtest CLI will do exactly that.

Speedtest CLI will allow to do a speedtest of your internet connection via for example SSH. It has quite some options, such as displaying the latency, or selection of the server (the software will prefer close-by servers for most accurate results).

sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian generic main" | sudo tee  /etc/apt/sources.list.d/speedtest.list
sudo apt-get update

 

Author Bio

Thank you for your interest in my blog! On this miniblog, I write mostly short (technical) blog posts that might interest other people. Read more about me or feel free to contact me.

 

Leave a Reply

Your email address will not be published. Required fields are marked *