linux系统如何测试下载速度
linux系统如何测试下载速度详细介绍
在 Linux 系统中测试下载速度可以通过多种命令行工具实现,以下是常用方法及操作步骤:
方法一:使用 wget(简单直观)
wget 是 Linux 自带的下载工具,下载时会显示实时速度,适合测试单个文件的下载速度。
操作步骤:
- 选择一个大文件的下载链接(确保链接有效,例如 Linux 镜像站的文件):
bashhttps://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso - 开始下载并观察速度:
下载过程中,wget会显示实时下载速度(单位为KB/s或MB/s),例如:
plaintextResolving mirrors.aliyun.com (mirrors.aliyun.com)... 116.211.63.123Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|116.211.63.123|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 614606848 (586M) [application/octet-stream]
Saving to: ‘CentOS-7-x86_64-Minimal-2009.iso’
CentOS-7-x86_64-Minimal-200 100%[===================================================================================>] 586.15M 5.21MB/s in 1m 53s
2025-04-15 14:30:20 (5.21 MB/s) - ‘CentOS-7-x86_64-Minimal-2009.iso’ saved [614606848/614606848]
最后一行的
5.21 MB/s即为下载速度。 - 下载后删除文件(避免占用空间):
bashCentOS-7-x86_64-Minimal-2009.iso
方法二:使用 curl(轻量工具)
curl 也可用于下载文件并显示速度,适合没有 wget 的环境。
操作步骤:
- 下载文件并显示进度:bash
https://example.com/large-file.zip-O参数表示按原文件名保存文件,输出中会显示实时速度(,输出中会显示实时速度(单位为MB/s或KB/s)。
方法三:使用 speedtest-cli(专业测速工具,基于 speedtest.net)
该工具可测试网络服务商的下载 / 上传速度,需先安装。
操作步骤:
- 安装工具:
- 通过
pip(适用于 Python 环境):bashpip speedtest-cli - 部分 Linux 发行版可直接通过包管理器安装(如 Ubuntu/Debian):bash
speedtest-cli
- 通过
- 运行测速:
bashspeedtest-cli工具会自动选择最佳服务器,显示下载速度、上传速度和延迟(单位为
Mbps),示例输出:
plaintextRetrieving speedtest.net configuration...Testing from China Telecom (xxx.xxx.xxx.xxx)...
Retrieving speedtest.net server list...
Selecting best server based on latency...
Hosted by China Telecom (Guangzhou) [123.45 km] [latency: 12.3 ms]
Testing download speed......
Download: 98.76 Mbps
Testing upload speed......
Upload: 45.67 Mbps
方法四:使用 axel(多线程下载,测试峰值速度)
axel 支持多线程下载,可测试网络的最大下载能力(需安装)。
操作步骤:
- 安装工具:
bashaxeldnf axel
- 多线程下载并显示速度:
bashaxel https://example.com/large-file.tar.gz-n 10表示使用 10 个线程,输出中会显示总速度(单位为KB/s或MB/s)。
注意事项
- 选择合适的文件 / 服务器:
- 文件大小建议至少 100MB,避免因文件太小导致测速不准确。
- 优先使用本地镜像站(如阿里云、腾讯云镜像)或常用公共服务器(如
http://ftp.debian.org)。
- 关闭其他网络应用:
确保无下载、视频播放、更新等占用带宽的程序,避免影响测试结果。 - 多次测试取平均值:
网络波动可能导致单次结果偏差,建议测试 2-3 次取平均值。 - 单位转换:
speedtest-cli的单位是 Mbps(兆比特 / 秒),1 Mbps = 125 KB/s(兆字节 / 秒)。wget/curl/axel的单位是 MB/s(兆字节 / 秒),1 MB/s = 8 Mbps。
根据需求选择工具:
- 简单快速:用
wget或curl下载大文件观察速度。 - 专业测速:用
speedtest-cli测试运营商网络速度。 - 峰值性能:用
axel多线程测试最大下载能力。