1、先要用wget命令从githubusercontent上下载Python脚本
wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
2、为speedtest.py
添加权限
chmod +rx speedtest.py
3、把执行的脚本speedtest.py
移动到 /usr/local/bin 文件夹,这样你就不用每次都输入完整的脚本路径了
/usr/local/bin 用户安装的可执行程序,不受系统升级影响,用户编译安装软件时,一般放到/usr/local目录下
sudo mv speedtest.py /usr/local/bin/speedtest-cli
sudo chown root:root /usr/local/bin/speedtest-cli
4、测速结果
[root@iZcyriae88knxxZ ~]# speedtest-cli
Retrieving speedtest.net configuration...
Testing from Hangzhou Alibaba Advertising Co.,Ltd. (47.97.184.137)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by China Telecom JiangSu 5G (Suzhou) [324.18 km]: 41.184 ms
Testing download speed................................................................................
Download: 101.87 Mbit/s
Testing upload speed................................................................................................
Upload: 1.26 Mbit/s