fir3net
PPS-Firenetbanner-780.5x190-30-03-17

How can I test the bandwith using a Linux shell ?

The other day I was faced with the problem of determining the networking bandwidth of a Linux system via just the shell.
After some googling and some head scratching I eventually came up with the following command.

echo "scale=2; `curl  --progress-bar -w "%{speed_download}" http://speedtest.wdc01.softlayer.com/downloads/test10.zip -o test.zip` / 131072" | bc | xargs -I {} echo {}Mb\/s

When testing there are 3 files you can use to test. These are:

      http://speedtest.wdc01.softlayer.com/downloads/test10.zip
      http://speedtest.wdc01.softlayer.com/downloads/test100.zip
      http://speedtest.wdc01.softlayer.com/downloads/test500.zip

These files are 10, 100 and 500Mb in size. Generally speaking a majority of people will be able to download the 10Mb file. If your download speed is over 20Mb then you may want to download the 100Mb file to ensure accurate results.

Example

[root@server ~]# echo "scale=2; `curl  --progress-bar -w "%{speed_download}" http://speedtest.wdc01.softlayer.com/downloads/test10.zip -o test.zip` / 131072" | bc | xargs -I {} echo {}Mb\/s
######################################################################## 100.0%
1.61Mb/s

Reference

The following link was a great help in determining the different bit to byte conversions - http://www.matisse.net/bitcalc/

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001