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
<class=”codemulti”></class=”codemulti”>

<class=”codemulti”>[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</class=”codemulti”>

Reference

<class=”codemulti”>The following link was a great help in determining the different bit to byte conversions – http://www.matisse.net/bitcalc/</class=”codemulti”>

Rick Donato

Want to become a Linux expert?

Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial