How To Test Internet Speed in Linux Using Terminal or SSH

If you want to check your Internet speed through your terminal this article will guide you an easy way. Most of the time we have to check our download and upload speed of our Linux server through ssh this can be an easy and fast way to test speed. But it’s not just restricted to Linux only! You can install python in MacOS or Windows and can run these both scripts to test internet speed from terminal and DoS.

Speedtest-cli

We have to install Speedtest-cli package first to use this tool. We’re going to need python.

Installing python

Type the following yum command to install Python on a CentOS/RHEL/Scientific Linux:

sudo yum install python

Type the following dnf command to install Python on a Fedora Linux v22+:

sudo dnf install python

Download speedtest_cli.py

Type the following wget command to grab the speedtest_cli.py client:

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

Check the Internet speed

After we’re done installing python and successfully downloaded speedtest-cli python package we can run it.

Simply run this following command:

./speedtest-cli

To see speed values in bytes instead of bits pass the --bytes option:

./speedtest-cli --bytes

To generate and provide a URL to the speedtest.net share results image pass the --share option:

./speedtest-cli --share

Of course, you can combine both the options:

./speedtest-cli --share --bytes

Specify a server ID to test against!

First, grab a server list, enter:

wget http://www.speedtest.net/speedtest-servers.php

To view a server ID, enter:

more speedtest-servers.php

To search a server ID, enter:

grep 'city-name' speedtest-servers.php
grep 'country-name' speedtest-servers.php
grep 'Tampa, FL' speedtest-servers.php
<server url="http://speedtest1.hivelocity.net/speedtest/upload.php" lat="27.9709" lon="-82.4646" name="Tampa, FL" country="United States" cc="US" sponsor="Hivelocity Hosting" id="2137"  host="speedtest1.hivelocity.net:8080" />
<server url="http://speedtestnet.rapidsys.com/speedtest/upload.php" lat="27.9709" lon="-82.4646" name="Tampa, FL" country="United States" cc="US" sponsor="Rapid Systems" id="1296"  host="speedtestnet.rapidsys.com:8080" />

OR just display a server ID:

grep 'Tampa, FL' speedtest-servers.php | egrep -o 'id="[0-9]{4}"'

Sample outputs:

id=”2137″
id=”1296″

Next use the server ID 2137:

./speedtest-cli --server 2137

Another command line utility for testing internet speed is Tespeed. This utlity tests your download and upload speed using five serves closest to your locations. It is also created using Python and requires Python 2.7 or higher versions to run.

What the script does:

  • Loads config from speedtest.net (http://speedtest.net/speedtest-config.php).
  • Gets server list (http://speedtest.net/speedtest-servers.php).
  • Picks 5 closests servers using the coordinates provides by speedtest.net config and serverlist.
  • Checks latency for those servers and picks one with the lowest.
  • Does download speed test and returns results.
  • Does upload speed test and returns results.
  • Optionally can return CSV formated results.
  • Can measure through SOCKS proxy.

TeSpeed: https://github.com/Janhouse/tespeed

Alternative speed test with speedcheck.org

Back to top button
Close