Linux常用命令--网络

写在前面:最近看趣谈网络协议,顺带复习一下Linux下常见的网络命令,本文持续更新

网络测速

speedtest-cli
顾名思义,这个命令为网络测速命令,基于Python编写,测试系统网络的上传下载速度,GitHub托管的项目地址,以下列出常见的用法
安装命令

pip install speedtest-cli

使用命令

# 查看帮助,具体选项说明自行查看,这里列出几个常用的
speedtest-cli -h
参数 说明 原文
-h, --help 显示帮助信息 show this help message and exit
--share 测试的同时分享测试结果图片到speedtest官网 Generate and provide a URL to the speedtest.net share results image
--simple 简化输出格式,只显示延迟,上传,下载 Suppress verbose output, only show basic information
--list 列出系统附近的测速服务器 Display a list of speedtest.net servers sorted by distance
--server SERVER 指定测速服务器的ID测速 Specify a server ID to test against. Can be supplied multiple times

查看测速服务器

# 打印全球的测速服务器,结果可能会非常多,可以重定向到文件保存,方便查看;或者只打印中国的测速服务器
speedtest-cli --list | grep -i 'china' > servers.txt

执行结果图
结果解释

17251) ChinaTelecom-GZ (Guangzhou, CN) [2.51 km]
# 拿以上第一条分析
17251:测速服务器ID
ChinaTelecom-GZ:中国广州电信,服务器运营商
Guangzhou, CN:中国广州,服务器地址
2.51 km:本机和测速服务器的距离,需要注意,list列出的服务器中,是按距离从小到大排序的

测速

# 指定某个测速服务器
speedtest-cli --server 17251
# 简化打印信息
speedtest-cli --server 17251 --simple

测速

一条命令测速

# 该命令默契情况下会选择最近距离的测速服务器作为测速
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -

需要注意,执行过程可能会超时,那么就分两步执行,下载测速脚本,用Python执行,和命令行用法一样,也可以加执行参数
一行式测速

小结:上图中的几次测速,可以看到延迟、上传、下载的数据不一致,说明这个工具只是当做参考,不能做唯一指标

猜你喜欢

转载自www.cnblogs.com/AutoSmart/p/10394877.html