aria2 使用指南

简介

aria2 是一个轻量级、多协议、多线程的命令行下载工具。纯 C 编写,内存占用极小,支持 HTTP(S)、FTP、SFTP、BitTorrent、Metalink 等多种协议。

核心优势: 多线程并行下载,把一个文件切成多块同时拉取,充分利用带宽。单线程跑 50KB/s,开 16 线程合起来就是 800KB/s。


一、安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Debian / Ubuntu
sudo apt install -y aria2

# CentOS / RHEL / Fedora
sudo dnf install -y aria2 # Fedora 22+
sudo yum install -y aria2 # CentOS 7

# macOS
brew install aria2

# Arch Linux
sudo pacman -S aria2

# 验证安装
aria2c --version

二、基本用法

命令是 aria2c(末尾的 c 代表 client)。

单文件下载

1
2
3
4
5
6
7
8
# 最简单:直接给 URL
aria2c https://example.com/file.zip

# 指定输出文件名
aria2c -o myfile.zip https://example.com/file.zip

# 指定保存目录
aria2c -d /path/to/dir https://example.com/file.zip

多线程加速(核心功能)

1
2
3
4
# -x: 每个服务器最大连接数(线程数)
# -s: 最大分片数
# 16 线程并行下载
aria2c -x 16 -s 16 https://example.com/large_file.iso

参数说明:

参数 含义 建议值
-x N 对同一服务器的最大连接数 16
-s N 文件分片数 与 -x 保持一致

注意: -x 不能高于 -s。实际效果取决于服务器是否支持 Range 请求(多线程分段下载的前提)。

断点续传

1
2
3
4
5
# -c: 自动检测已有文件,从断点继续(布尔值,不需要跟参数)
aria2c -c https://example.com/file.zip

# 结合多线程
aria2c -c -x 16 -s 16 https://example.com/file.zip

批量下载

1
2
3
4
5
# 多个 URL 空格分隔
aria2c https://a.com/1.zip https://b.com/2.zip https://c.com/3.zip

# 从文件读取 URL 列表(每行一个)
aria2c -i urls.txt

urls.txt 示例:

1
2
3
4
5
6
https://example.com/file1.iso
dir=/path/to/save
out=renamed1.iso
https://example.com/file2.iso
dir=/path/to/save
out=renamed2.iso

三、进阶用法

限速

1
2
3
4
5
# 限制总下载速度
aria2c --max-download-limit=1M https://example.com/file.zip

# 限制单个连接速度
aria2c --max-overall-download-limit=5M https://example.com/file.zip

设置代理

1
2
3
4
5
# HTTP 代理
aria2c --all-proxy="http://127.0.0.1:7890" https://example.com/file.zip

# 仅 HTTP
aria2c --http-proxy="http://127.0.0.1:7890" https://example.com/file.zip

最大并发任务数

1
2
# 同时下载 5 个文件(默认 5)
aria2c -j 10 https://a.com/1.zip https://b.com/2.zip ...

BT / 磁力链接下载

1
2
3
4
5
6
7
8
9
10
11
# 种子文件
aria2c example.torrent

# 磁力链接(用引号包起来)
aria2c "magnet:?xt=urn:btih:XXXX..."

# 选择下载种子中的特定文件
aria2c --select-file=1,3 example.torrent

# BT 下载限速
aria2c --seed-time=0 example.torrent # 下载完不做种

安静模式 / 控制台输出

1
2
3
4
5
6
7
8
# 安静模式:只显示下载进度条,不显示详细日志
aria2c -q https://example.com/file.zip

# 完全无输出
aria2c --quiet https://example.com/file.zip

# 显示调试信息
aria2c --log-level=debug https://example.com/file.zip

校验下载

1
2
3
4
5
# 下载后自动校验 checksum
aria2c --checksum=sha-256=abc123... https://example.com/file.zip

# 配合 sha256sum 手动校验
echo "abc123... file.zip" | sha256sum -c

四、配置文件

aria2 支持配置文件,避免每次输入一堆参数。默认路径:

  • Linux: ~/.aria2/aria2.conf
  • macOS: ~/.aria2/aria2.conf

常用配置示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# ~/.aria2/aria2.conf

# 下载目录
dir=/home/user/Downloads

# 每个服务器最大连接数(线程数)
max-connection-per-server=16
# 文件分片数
split=16

# 断点续传
continue=true

# 最大并发任务数
max-concurrent-downloads=5

# 限速(0 = 不限速)
max-overall-download-limit=0

# 安静模式
quiet=false

# 代理
# all-proxy=http://127.0.0.1:7890

# 保存会话(断点续传信息),重启后可继续
save-session=~/.aria2/aria2.session
save-session-interval=30

# BT 设置
bt-max-peers=128
seed-time=0
enable-dht=true
bt-enable-lpd=true

使用配置文件

1
2
3
4
5
# 自动读取 ~/.aria2/aria2.conf
aria2c https://example.com/file.zip

# 指定配置文件
aria2c --conf-path=/path/to/custom.conf https://example.com/file.zip

五、RPC 模式(远程控制)

aria2 可以以后台守护进程模式运行,通过 JSON-RPC 接口接收下载任务。配合 WebUI(如 AriaNg)可实现图形化远程管理。

启动 RPC 模式

1
2
3
4
5
# 基本 RPC 模式
aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all

# 带密钥的 RPC(防止未授权访问)
aria2c --enable-rpc --rpc-secret=mypassword --rpc-listen-port=6801

用 curl 调用 RPC

1
2
3
4
5
6
7
# 添加下载任务
curl "http://localhost:6800/jsonrpc" \
-d '{"jsonrpc":"2.0","id":"1","method":"aria2.addUri","params":["token:mypassword",["https://example.com/file.zip"]]}'

# 查看下载状态
curl "http://localhost:6800/jsonrpc" \
-d '{"jsonrpc":"2.0","id":"2","method":"aria2.tellActive","params":["token:mypassword"]}'

作为 systemd 服务运行

1
2
3
4
5
6
7
8
9
10
11
# ~/.config/systemd/user/aria2.service
[Unit]
Description=aria2 RPC Daemon
After=network.target

[Service]
ExecStart=/usr/bin/aria2c --conf-path=%h/.aria2/aria2.conf
Restart=on-failure

[Install]
WantedBy=default.target
1
systemctl --user enable --now aria2

六、实战场景

场景一:下载国内网络慢的大文件(如 kubectl、minikube)

1
2
aria2c -x 16 -s 16 -o kubectl \
"https://dl.k8s.io/release/v1.36.2/bin/linux/amd64/kubectl"

单线程 50KB/s → 多线程 800KB/s,56MB 文件约 1 分钟搞定。

场景二:下载 GitHub Release 文件(国内直连慢)

1
2
aria2c -x 16 -s 16 \
"https://github.com/user/repo/releases/download/v1.0/archive.zip"

场景三:配合镜像站批量下载

1
2
# 从 URL 列表批量下载
aria2c -x 8 -s 8 -i urls.txt

场景四:断网后断点续传

1
2
# 中断后重新执行相同命令,自动续传
aria2c -c -x 16 -s 16 https://example.com/huge_file.iso

七、常用命令速查

场景 命令
快速下载 aria2c <URL>
多线程加速 aria2c -x 16 -s 16 <URL>
指定文件名 aria2c -o name.zip <URL>
指定目录 aria2c -d /path <URL>
断点续传 aria2c -c <URL>
终极组合 aria2c -c -x 16 -s 16 -o name <URL>
批量下载 aria2c -i urls.txt
磁力链接 aria2c "magnet:?xt=urn:btih:..."
种子文件 aria2c file.torrent
限速 1MB/s aria2c --max-download-limit=1M <URL>
代理下载 aria2c --all-proxy="http://127.0.0.1:7890" <URL>

八、对比其他工具

工具 多线程 断点续传 BT/磁力 轻量 命令行
aria2
curl ✅ (-C)
wget ✅ (-c)
axel
uGet

aria2 几乎是命令行下载工具中最全能的,既轻量又支持多协议多线程。


aria2 使用指南
https://bote798.top/2026/07/11/aria2使用指南/
作者
bote798
发布于
2026年7月11日
更新于
2026年7月11日
许可协议