speedtest-cli is available from the Ubuntu repositories.

sudo apt install speedtest-cli

After the installation is completed, simply run speedtest-cli
Here is an example of my mobile connection speeds

➜  janostech speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Vodafone Limited (85.***.***.***)...
Selecting best server based on latency...
Hosted by Vodafone UK (London) [5.34 km]: 74.778 ms
Testing download speed........................................
Download: 10.68 Mbit/s
Testing upload speed..................................................
Upload: 12.68 Mbit/s
➜  janostech