Testing the upload and download speed of a internet connection from the terminal, can be as simple as installing a small program known as speedtest-cli. This is perhaps mainly useful for servers in the cloud, where you normally do not have access to a desktop, and thereby a browser to visit test websites with. That is, unless you install remote-desktop software.
Before you can use this command line tool, you will first have to install it. This can either be done manually, or by using the pip command, which is a tool for installing and managing Python packages.
Install speedtest-cli using pip command
You might also need to install the pip tool first, so start by entering the below into a terminal window:
sudo apt-get install python-pip
This will install pip and allow you to finally install speedtest-cli by entering:
sudo pip install speedtest-cli
After completing this final step, you can test the internet connection by entering speedtest-cli in a terminal window.
Install speedtest-cli manually
While this may seem more complicated, it actually is not, and it dose give you an idea about how packages can otherwise be installed, which can be relevant if the automatic method is our of date. Start by entering the following:
sudo wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
After downloading the speedtest_cli.py file, you need to make it executable, which can be done with the chmod command. So, enter the command in your terminal window:
sudo chmod a+rx speedtest_cli.py
Finally, you just need to move the file to /usr/bin/speedtest-cli, to make the command available in terminal, which can be done with the mv command in a terminal:
sudo mv speedtest_cli.py /usr/bin/speedtest-cli
Now you just enter speedtest-cli in terminal, to test the internet connection speeds.
Testing connection bandwidth speed with speedtest-cli
After having installed the speedtest tool, you can test the upload and download speeds by entering the following command in a terminal:
The speedtest tool will then automatically attempt to find the closest server to the location of the computer it is running on.
Download and upload speeds on shared connections
If you are trying to test a virtual server in the cloud, then you should remember that your the connection bandwidth is most likely shared with other virtual servers, and the result will therefor depend on how heavily the connection is being used, at the time of the test.