Update in 2016:
speedtest-cli is in Ubuntu repositories now. For Ubuntu 16.04 (Xenial) and later use:
sudo apt install speedtest-cli
speedtest-cli
Update in 2018:
Using pip install --user speedtest-cli
gets you a version that is probably newer than the one available from your distribution’s repositories.
speedtest-cli
Update in 2022:
sudo apt install speedtest-cli
speedtest-cli --secure