Linux Speedtest installation and use - Tech

  1. Portal Home
  2. Tech

Linux Speedtest installation and use

  Very often we need to test the uplink and downlink broadband of a Linux server. Speedtest.net is perhaps "one of the most widely used" applications on the web for testing broadband speeds. Speedtest.net comes with a command line version, speedtest-cli. Here we will show you how to use speedtest-cli to test the speed of a broadband connection from the Linux command line.

1. install speedtest-cli
  speedtest-cli is a lightweight Linux command-line tool written in Python that runs under Python versions 2.4 to 3.4. It is based on the Speedtest.net infrastructure to measure the network up/down speed. Installing speedtest-cli is very simple, just download its Python script file. The steps are as follows

wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
mv speedtest.py /usr/local/bin/speedtest
chown root:root /usr/local/bin/speedtest

2. the use of speedtest-cli test network speed
Using the speedtest-cli command is also simple, it doesn't require any parameters to work.

[[email protected] ~]# speedtest

After entering this command, it will automatically discover the closest Speedtest.net server to you (geographic distance) and print out the tested network uplink/downlink rate

Retrieving speedtest.net configuration...
Testing from China Telecom Hainan (112.67.250.27)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GX-Telecom (Nanning) [372.63 km]: 29.374 ms
Testing download speed...................................
Download: 94.70 Mbit/s
Testing upload speed...................................
Upload: 4.24 Mbit/s

The test result is 4.24Mbit/s for upstream and 94.70 Mbit/s for downstream, but it may not be possible to reach this value in the actual application.

speedtest can use the speedtest-cli --list command to get all the test nodes for speedtest and we can use the grep command to get the Chinese nodes. Example.

speedtest-cli --list | grep China
[[email protected] ~]# speedtest --list | grep China
26331) Henan CMCC 5G (Zhengzhou, China) [9.69 km]
 5396) China Telecom JiangSu 5G (Suzhou, China) [324.18 km]
26501) shanxi CMCC 5G (Taiyuan, China) [359.85 km]
 5039) China unicom Jinan branch (Jinan, China) [361.63 km]
26180) Shandong Unicom 5G (Jinan, China) [361.63 km]
25881) ShanDong CMCC 5G (Jinan, China) [361.63 km]
27151) ShanDong CMCC 5G (Linyi, China) [423.60 km]
26380) Shaanxi china mobile (xi‘an, China) [440.92 km]
 4863) Xi'an branch,Chinaunicom (Xi'an, China) [445.72 km]
29105) 陕西移动5G (Xi'an, China) [445.72 km]
17145) China Telecom AnHui 5G (Hefei, CN) [462.12 km]
26404) 安徽移动5G (Hefei, China) [462.12 km]
 5724) ChinaUnicom (Hefei, China) [462.12 km]
26547) China Mobile HuBei CO., Ltd (Wuhan, China) [468.72 km]
29353) wuhan hello 5G (Wuhan, China) [468.72 km]
23844) China Telecom Wuhan Branch (Wuhan, China) [468.72 km]
 5485) China Unicom,Hubei Branch (Wuhan, China) [468.72 km]
 5317) China Telecom JiangSu 5G (Lianyungang, China) [497.72 km]
26352) China Telecom JiangSu 5G (Nanjing, China) [557.10 km]
13704) China Unicom (Nanjing, China) [558.81 km]
27249) China Mobile jiangsu 5G (Nanjing, China) [558.81 km]
27154) ChinaUnicom-5G (TianJin, China) [573.88 km]
17184) China Mobile TianJin-5G (Tianjin, CN) [601.84 km]
17320) China Mobile JiangSu 5G (ZhenJiang, China) [602.34 km]
 5145) Beijing Unicom (Beijing, China) [618.26 km]
25858) China Mobile Group Beijing Co.Ltd (Beijing, China) [618.26 km]
 5505) Beijing Broadband Network (Beijing, China) [618.26 km]
27377) China Telecom 5G (Beijing, China) [618.26 km]
27100) ShanDong CMCC 5G (Qingdao, China) [619.94 km]
32291) China Mobile 5G (ChangZhou, China) [667.34 km]
30232) NeiMeng CMCC 5G (Hohhot, China) [696.86 km]
24012) China Telecom Inner Mongolia Branch-1 (Huhhot, China) [696.86 km]
25883) 江西移动5G (NanChang, China) [706.45 km]
26850) China Mobile 5G (Wuxi, China) [707.85 km]

In the list above, each line is preceded by an ID corresponding to the server, and if you want to use the specified node to test your internet speed, you just need to specify its ID after the speedtest command. For example, if you want to use the Shaanxi Mobile server shown above, you just need to specify the corresponding server ID 29105.

[[email protected] ~]# speedtest --server 29105
Retrieving speedtest.net configuration...
Testing from Ankang Puchuang Network Technology Co. (103.146.88.10)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by Shaanxi 5G (Xi'an) [445.72 km]: 70.016 ms
Testing download speed...................................
Download: 2.53 Mbit/s
Testing upload speed...................................
Upload: 5.82 Mbit/s
[[email protected] ~]#