• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Tips & Tricks

How to test internet speed in Linux terminal

Published: October 10, 2017 | Modified: June 25, 2020



Learn how to use speedtest CLI tool to test internet speed in the Linux terminal. It also includes a one-liner python command to get speed details right away.

Internet speed check in Linux

Most of us check the internet bandwidth speed whenever we connect to a new network or wifi. So why not our servers! Here is a tutorial that will walk you through to test internet speed in the Linux terminal.

Every one of us generally uses Speedtest by Ookla to check internet speed. It’s a pretty simple process for a desktop. Go to their website and just click the GO button. It will scan your location and speed test with the nearest server.  If you are on mobile, they have their app for you. But if you are on the terminal with command-line interface things are little different. Let’s see how to check internet speed from the Linux terminal.

If you want to speed check only once and don’t want to download the tool on the server, jump here and see one-liner command.

Step 1 : Download speedtest cli tool

First of all, you have to download speedtest CLI tool from the GitHub repository. Nowadays, it also included in many well known Linux repositories as well. If it’s there then you can directly install that package on your Linux distro.

Let’s proceed with the Github download and install process. Install the git package depending on your distro. Then clone Github repo of speedtest like below:

[root@kerneltalks ~]# git clone https://github.com/sivel/speedtest-cli.git
Cloning into 'speedtest-cli'...
remote: Counting objects: 913, done.
remote: Total 913 (delta 0), reused 0 (delta 0), pack-reused 913
Receiving objects: 100% (913/913), 251.31 KiB | 143.00 KiB/s, done.
Resolving deltas: 100% (518/518), done.

It will be cloned to your present working directory. A new directory named speedtest-cli will be created. You can see the below files in it.

[root@kerneltalks ~]# cd speedtest-cli
[root@kerneltalks speedtest-cli]# ll
total 96
-rw-r--r--. 1 root root  1671 Oct  7 16:55 CONTRIBUTING.md
-rw-r--r--. 1 root root 11358 Oct  7 16:55 LICENSE
-rw-r--r--. 1 root root    35 Oct  7 16:55 MANIFEST.in
-rw-r--r--. 1 root root  5215 Oct  7 16:55 README.rst
-rw-r--r--. 1 root root    20 Oct  7 16:55 setup.cfg
-rw-r--r--. 1 root root  3196 Oct  7 16:55 setup.py
-rw-r--r--. 1 root root  2385 Oct  7 16:55 speedtest-cli.1
-rw-r--r--. 1 root root  1200 Oct  7 16:55 speedtest_cli.py
-rwxr-xr-x. 1 root root 47228 Oct  7 16:55 speedtest.py
-rw-r--r--. 1 root root   333 Oct  7 16:55 tox.ini

The python script speedtest.py is the one we will be using to check internet speed.

You can link this script for a command in /usr/bin so that all users on the server can use it. Or you can even create command alias for it and it will be easy for all users to use it.

Step 2 : Run python script

Now, run a python script without any argument and it will search the nearest server and test your internet speed.

[root@kerneltalks speedtest-cli]# python speedtest.py
Retrieving speedtest.net configuration...
Testing from Amazon (35.154.184.126)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Spectra (Mumbai) [1.15 km]: 8.174 ms
Testing download speed................................................................................
Download: 548.13 Mbit/s
Testing upload speed................................................................................................
Upload: 323.95 Mbit/s

I am on the AWS EC2 Linux server. That’s the bandwidth of the Amazon data center! 🙂

Different options with script

Few options which might be useful are as below :

To search speedtest servers nearby your location use --list switch and grep for your location name.

[root@kerneltalks speedtest-cli]#  python speedtest.py --list | grep -i mumbai
 2827) Bharti Airtel Ltd (Mumbai, India) [1.15 km]
 8978) Spectra (Mumbai, India) [1.15 km]
 4310) Hathway Cable and Datacom Ltd (Mumbai, India) [1.15 km]
 3315) Joister Broadband (Mumbai, India) [1.15 km]
 1718) Vodafone India (Mumbai, India) [1.15 km]
 6454) YOU Broadband India Pvt Ltd. (Mumbai, India) [1.15 km]
 9764) Railtel Corporation of india Ltd (Mumbai, India) [1.15 km]
 9584) Sheng Li Telecom (Mumbai, India) [1.15 km]
 7605) Idea Cellular Ltd. (Mumbai, India) [1.15 km]
 8122) Sify Technologies Ltd (Mumbai, India) [1.15 km]
 9049) I-ON (Mumbai, India) [1.15 km]
 6403) YOU Broadband India Pvt Ltd., Mumbai (Mumbai, India) [1.15 km]

You can see here, the first column is a server identifier followed by the name of the company hosting that server, location, and finally its distance from your location.

To test the internet speed using specific server use --server switch and server identifier from the previous output as an argument.

[root@kerneltalks speedtest-cli]# python speedtest.py --server 2827
Retrieving speedtest.net configuration...
Testing from Amazon (35.154.184.126)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Bharti Airtel Ltd (Mumbai) [1.15 km]: 13.234 ms
Testing download speed................................................................................
Download: 93.47 Mbit/s
Testing upload speed................................................................................................
Upload: 69.25 Mbit/s

To get the share link of your speed test, use –share switch. It will give you the URL of your test hosted on speedtest website. You can share this URL.

[root@kerneltalks speedtest-cli]# python speedtest.py --share
Retrieving speedtest.net configuration...
Testing from Amazon (35.154.184.126)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Spectra (Mumbai) [1.15 km]: 7.471 ms
Testing download speed................................................................................
Download: 621.00 Mbit/s
Testing upload speed................................................................................................
Upload: 367.37 Mbit/s
Share results: http://www.speedtest.net/result/6687428141.png

Observe the last line which includes the URL of your test result. If I download that image its the one below :

Speedtest result on Linux

That’s it! But hey if you don’t want all this technical jargon, you can even use below one-liner to get speed test done right away.

Internet speed test using one liner in terminal

We are going to use a curl tool to fetch the above python script online and supply it to python for execution on the go!

[root@kerneltalks ~]# curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -

Above command will run the script and show you result on screen!

[root@kerneltalks speedtest-cli]# curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
Retrieving speedtest.net configuration...
Testing from Amazon (35.154.184.126)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Spectra (Mumbai) [1.15 km]: 12.599 ms
Testing download speed................................................................................
Download: 670.88 Mbit/s
Testing upload speed................................................................................................
Upload: 355.84 Mbit/s

I tested this tool on RHEL 7 server but the process is same on Ubuntu, Debian, Fedora, or CentOS.

⇠ Previous article
Understand data center tiers: tier 1 to tier 4
Next article ⇢
mount.nfs: requested NFS version or transport protocol is not supported

Related stuff:

  • How to list open ports on Linux/Unix server
  • Create beautiful ASCII text banners in Linux
  • Cowsay: Fun in Linux terminal
  • Hollywood movie MATRIX like desktop in Linux terminal
  • 8 ways to generate random password in Linux
  • How to get directory size in Linux
  • 4 tools to download any file using the command line in Linux
  • Format date and time for Linux shell script or variable
  • 3 tricks to get multiple commands output in the same row
  • How to save PuTTY session output automatically
  • How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora)
  • How to change UID or GID safely in Linux

Filed Under: Tips & Tricks Tagged With: linux network speed test, linux test upload speed, speedtest-cli centos, test internet speed terminal mac

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Comments

  1. :Richard says

    October 15, 2017 at 2:04 am

    F.Y.I.
    I am on Ubuntu 14.04-2 4.4.97.0
    I had to clone from Github as using synaptic install speedtest was not found.
    and had to use following:
    ~/.local/share/speedtest-cli /usr/bin/python speedtest.py
    results:
    Testing download speed………………………………….
    Download: 11.10 Mbit/s
    Testing upload speed…………………………………………..
    Upload: 5.03 Mbit/s
    via VPN
    I do not have a landline but wireless on my desktop.
    I AM happy with performance.
    F.Y.i.

    Reply
    • Shrikant Lavhate says

      October 16, 2017 at 2:28 pm

      Thanks Richard for sharing this one. Will be helpful for other readers.

      Reply
  2. Josh says

    October 17, 2017 at 8:07 pm

    I’ve actually been using speedtest-cli for years. It’s a great CLI utility. It’s especially useful because it allows you to check the speed of your Internet connection, even when it’s too slow to be able to render speedtest.net in a reasonable amount of time. There’s also less visual fluff than using speedtest.net. I also think it looks cooler than just using speedtest.net directly. Though, I started using speedtest-cli on MacOS. Since MacOS doesn’t have a package manager like apt or RPM, I had to install it with a package manager called Homebrew – which does not come with MacOS.

    Reply

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2026 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.