Lets say you are logged into a headless server (command line only) and you get a call about slow internet performance across network. Now of course there might be hundreds of reasons for slowness but you managed to narrow it down to the correction between your Gateway proxy and Upper stream provider. So, obviously before you call your Internet service provider and complain about slow connection you need to make sure exactly how slow the connection is right now. Ideally, if you were using a Desktop Manager, you could just fire-up a web browser and test your internet speed against sites like speedtest.net, or others. But you are in a headless server, no browser, no java, no flash. What to do? Well, fear not, you are using Linux and that means you can check download speed from Linux terminal easily. There are many different ways you can do it.
Option 1: Using speedtest-cli
First you need to install python-pip package
apt-get install python-pip
Next you install speedtest-cli via pip.
pip install speedtest-cli
and finally you just simply run speedtest-cli command in your terminal
Option 2: Using wget
To use it just point to a file in internet that is relatively bigger so that you can get a better estimate of it.
For example :
wget http://hostve.com/neobuntu/pics/Ubu1.avi would start to download the Ubu1.avi file and show at what speed it is downloading.
Of course there are several recommendations:
- Speed test yourself with good servers. In the case of my link the speed is less than 200KB so if you have a higher speed, the server will be the bottleneck for you, not your actual speed.
- The highest speed you will see is the maximum speed that your connection and the server’s connection can offer. If your connection is 512KB and the place where you are downloading is 400KB, your max connection will be 400KB because it is the max for the server you are downloading from.
- You need to do the test at least 5 times to have a reliable speed check or at least do it for a minute or two. This will help you have a more accurate check.
- You need to have at least 4 or 5 different testing sources to have a more accurate speed. Never test only from the same site as this can be affected by your distance to it, any problem in the server and the connections to it, etc. Always test from different servers.
Option 3: Using aria2
This is an alternative to
wget. The downside of
wgetis the lack of parallel connections. To use aria2 we fist need to download it:
apt-get install aria2
To use it is simple:
In the image, the -x 4is how many parallel connections we wish to use. The CN parameter in the next line shows how many active parallel connections were permitted to download from that site. In this case CN is 4. But if we tried to have more connections we would get something like this:
We set 8 parallel connections but the site only allowed a maximum of 5 as shown by CN:5. This could be solved by the-j option which tells aria2c the maximum concurrent connections we want (Which by default is 5) but if the server has limited this, -j will not work.