随笔 - 6  文章 - 118  评论 - 1  阅读 - 12315

Linux 下aria2 下载神器使用详解

简介

aria2 是一个轻量级的多协议命令行下载实用工具。它支持各种协议,如HTTP, HTTPS, FTP, SFTP, BitTorrent和Metalink。它以使用多个连接同时从多个来源下载文件的能力而闻名,从而提高了下载速度。

安装

  • Debian/Ubuntu
sudo apt update
sudo apt install aria2
  • CentOS/RHEL
sudo yum install aria2
  • Fedora
sudo dnf install aria2

示例用法

下载单个文件

aria2c http://example.com/file.zip

下载多个文件

aria2c http://example.com/file1.zip http://example.com/file2.zip

使用恢复支持下载文件

-c:可以恢复之前中断的下载

aria2c -c http://example.com/largefile.zip

使用多个连接下载文件

默认情况下,aria2 仅使用一个连接来下载文件。要使用多个连接(也称为多线程下载),使用 -x 选项,后跟连接数。

aria2c -x 4 http://example.com/largefile.zip

Metalink 是一种提供文件镜像和校验和列表的格式

aria2c metalink://example.com/file.metalink

从 Torrent 文件下载

使用 aria2 通过 BitTorrent 下载文件

aria2c example.torrent

使用磁力链接下载

aria2c "magnet:?xt=urn:btih:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

设置下载速度限制

aria2c --max-download-limit=500K http://example.com/file.zip

下载到特定目录

aria2c -d /path/to/directory http://example.com/file.zip

后台下载(守护进程模式)

aria2c --daemon http://example.com/file.zip

aria2 配置文件

可以使用配置文件来设置 aria2 的默认参数。配置文件通常位于 ~/.aria2/aria2.conf

# aria2.conf
continue=true
max-connection-per-server=4
dir=/path/to/downloads
max-download-limit=1M

使用配置文件运行 aria2

aria2c --conf-path=/path/to/aria2.conf http://example.com/file.zip

将 aria2 与 JSON-RPC 结合使用

aria2 支持通过 JSON-RPC 进行远程控制,可以通过编程方式或远程方式与程序进行交互

启动 aria2c RPC 服务器

aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-listen-port=6800
  • --enable-rpc:启用 RPC 模式

  • --rpc-listen-all=true:允许来自任何 IP 的连接

  • --rpc-allow-origin-all:允许跨源请求

  • --rpc-listen-port=6800:监听端口 6800

显示下载进度

aria2c -q --show-console-readout=false http://example.com/file.zip
  • -q:安静模式(抑制控制台输出)

  • --show-console-readout=false:禁用控制台读数以获得更清晰的显示

检查下载速度

可以通过指定 -j(最大并发下载数量)来获取当前下载速度

aria2c -j 4 http://example.com/file.zip

检查文件完整性(哈希检查)

通过检查校验和

aria2c --check-integrity http://example.com/file.zip

使用 Cron 自动进行每日下载

0 3 * * * /usr/bin/aria2c -d /path/to/directory http://example.com/dailyfile.zip
posted on   我是唐青枫  阅读(187)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

点击右上角即可分享
微信分享提示