axel
axel
是一个高效的命令行下载工具,专为 Linux 环境设计。它支持 HTTP 和 FTP 协议,通过多线程下载和断点续传功能显著提升下载速度。axel
可以同时从多个地址或同一地址的多个连接下载单个文件,非常适合在网络速度较慢的情况下使用。axel
的表现通常优于 wget
。需要注意的是,axel
仅提供命令行界面。但它有一个问题,对于重定向链接下载支持不够友好(2.17.12 已优化此功能,效果一般),但下载速度相对于 wget
来说更快。
macOS
macOS 安装比较简单,使用 brew
命令安装即可。brew
命令行工具安装,参考链接:macOS 包管理器 Homebrew
brew install axel
Red Hat 系
对于 Red Hat 系 Linux 需要手动编译安装。Github 下载链接:Releases · axel-download-accelerator/axel
# 安装编译所需要的软件
[root@localhost ~]# dnf install gcc clang make openssl-devel
# 下载源码
[root@localhost ~]# wget https://github.com/axel-download-accelerator/axel/releases/download/v2.17.14/axel-2.17.14.tar.gz
# 解压
[root@localhost ~]# tar -zxvf axel-2.17.14.tar.gz
# 进入目录
[root@localhost ~]# cd axel-2.17.14
# 编译
[root@localhost axel-2.17.14]# ./configure && make && make install
# 将编译成功后的 axel 直接复制到 /usr/bin 即可
[root@localhost axel-2.17.14]# cp axel /usr/bin
# 获取帮忙信息
[root@localhost axel-2.17.14]# axel -h
Axel 2.17.14 (linux-gnu)
Usage: axel [options] url1 [url2] [url...]
--max-speed=x -s x Specify maximum speed (bytes per second) # 指定最大速度(每秒字节数)
--num-connections=x -n x Specify maximum number of connections # 指定最大连接数
--max-redirect=x Specify maximum number of redirections # 指定最大重定向数
--output=f -o f Specify local output file # 指定本地输出文件
--search[=n] -S[n] Search for mirrors and download from n servers # 搜索镜像并从 n 个服务器下载
--ipv4 -4 Use the IPv4 protocol # 使用 IPv4 协议
--ipv6 -6 Use the IPv6 protocol # 使用 IPv6 协议
--header=x -H x Add HTTP header string # 添加 HTTP 标头字符串(指定 HTTP header)
--user-agent=x -U x Set user agent # 设置用户代理(指定 HTTP user agent)
--no-proxy -N Just don't use any proxy server # 不使用任何代理服务器
--insecure -k Don't verify the SSL certificate # 不验证 SSL 证书
--no-clobber -c Skip download if file already exists # 如果文件已存在则跳过下载
--quiet -q Leave stdout alone # 静默模式
--verbose -v More status information # 更多状态信息
--alternate -a Alternate progress indicator # 备用进度指示器
--percentage -p Print simple percentages instead of progress bar (0-100) # 打印简单百分比而不是进度条(0-100)
--help -h This information # 帮助信息
--timeout=x -T x Set I/O and connection timeout # 设置 I/O 和连接超时
--version -V Version information # 版本信息
Debian 系
Debian 系 Linux,可以直接使用 apt
进行安装。
apt install axel
其它 Linux 发行版安装
其它 Linux 发行版安装,可以从此链接 Packages for Linux and Unix 下载对应包进行安装。
使用方法
# 直接下载
axel -n 20 https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
# 带重定向链接下载,设置最大重定向次数,一般也就 1-2 次即可。
axel -n 20 --max-redirect=5 "https://hf-mirror.com/google-bert/bert-base-uncased/resolve/main/flax_model.msgpack?download=true"
大模型文件下载:
axel -n 10 -o seedvr2_ema_3b_fp16.safetensors "https://huggingface.co/numz/SeedVR2_comfyUI/resolve/main/seedvr2_ema_3b_fp16.safetensors"
命令解释:
-n 10
: 指定使用 10 个线程进行下载。您可以根据您的网络情况调整这个数字,比如:-n 16
。这是提升速度的关键参数。-o seedvr2_ema_3b_fp16.safetensors
: 指定输出的文件名。这和wget
的-O
以及curl
的-o
作用一样。
一个非常棒的特性是,axel
默认就支持断点续传。如果下载意外中断,您只需要在同一个目录下重新执行完全相同的命令,它会自动从上次停止的地方继续下载。
aria2
aria2
是一款功能强大的命令行下载工具,支持多协议、多线程、断点续传等功能,包括:
- 多协议支持:
aria2
支持 HTTP、HTTPS、FTP、SFTP、BitTorrent 和 Metalink 等多种下载协议,适用于各种下载需求。
- 多线程下载:
aria2
支持从多个源同时下载文件,能够显著提高下载速度。
- 断点续传:
- 支持断点续传功能,如果下载中断,可以从断点处继续下载,不必重新开始。
- 轻量级:
aria2
是一个轻量级工具,占用资源少,适合在服务器或嵌入式设备上运行。
- 灵活配置:
- 提供丰富的配置选项和参数,可以根据需要定制下载行为。
- API 支持:
aria2
提供 JSON-RPC 和 XML-RPC 接口,方便集成到其他应用程序或脚本中。
GitHub 链接:GitHub - aria2/aria2: aria2
安装
基本上所有常用 Linux 操作系统都可以通过软件包直接安装。
# macOS
brew install aria2
# Red Hat 系
dnf install aria2 -y
# Debian 系
apt install aria2 -y
使用方法
# 获取帮忙信息
[root@localhost ~]# aria2c -h
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
Printing options tagged with '#basic'.
See 'aria2c -h#help' to know all available tags.
Options:
-v, --version Print the version number and exit.
Tags: #basic
-h, --help[=TAG|KEYWORD] Print usage and exit.
The help messages are classified with tags. A tag
starts with "#". For example, type "--help=#http"
to get the usage for the options tagged with
"#http". If non-tag word is given, print the usage
for the options whose name includes that word.
Possible Values: #basic, #advanced, #http, #https, #ftp, #metalink, #bittorrent, #cookie, #hook, #file, #rpc, #checksum, #experimental, #deprecated, #help, #all
Default: #basic
Tags: #basic, #help
-l, --log=LOG The file name of the log file. If '-' is
specified, log is written to stdout.
Possible Values: /path/to/file, -
Tags: #basic
......(略)
# 多线程下载,自动重定向链接
aria2c -x 16 https://hf-mirror.com/benjamin-paine/ccsr/resolve/main/real-world_ccsr.ckpt?download=true
# 多源下载
cat urls.txt
http://example.com/file.zip
http://mirror.example.com/file.zip
aria2c -i urls.txt
# BitTorrent 下载
aria2c file.torrent
# 磁力链接下载
aria2c 'magnet:?xt=urn:btih:...'
大模型文件下载:
aria2c -c -x 10 -s 10 -o seedvr2_ema_3b_fp16.safetensors "https://huggingface.co/numz/SeedVR2_comfyUI/resolve/main/seedvr2_ema_3b_fp16.safetensors"
命令解释:
-c
:--continue
,断点续传。-x 10
:--max-connection-per-server
,设置每个服务器的最大连接数。这里设置为10
个线程。您可以根据网络情况调整。-s 10
:--split
,设置将文件分割成多少块来下载。通常与-x
的值保持一致。-o seedvr2_ema_3b_fp16.safetensors
: 指定输出文件名。
配置文件
aria2
可以通过配置文件来设置默认参数,配置文件通常位于 ~/.aria2/aria2.conf
。以下是一个简单的配置示例:
# ~/.aria2/aria2.conf
dir=/path/to/download
file-allocation=falloc
max-connection-per-server=16
continue=true
curl
curl
是另一个强大的数据传输工具,也通常被预装。
大模型文件下载:
curl -L -C - -o seedvr2_ema_3b_fp16.safetensors "https://huggingface.co/numz/SeedVR2_comfyUI/resolve/main/seedvr2_ema_3b_fp16.safetensors"
命令解释:
-L
:--location
的缩写,表示自动跟随重定向。Hugging Face 的下载链接会重定向到实际的文件服务器,所以这个参数是必须的。-C -
:--continue-at
的缩写,-
表示自动寻找断点,实现断点续传。-o seedvr2_ema_3b_fp16.safetensors
:--output
的缩写,将下载内容保存到指定文件中(而不是打印在终端上)。
使用 curl 命令下载 GitHub releases 包:
curl -LJO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
wget
wget
是一个非常经典且功能强大的下载工具,几乎所有 Linux 发行版都预装,它默认支持断点续传。
大模型文件下载:
wget -c -O seedvr2_ema_3b_fp16.safetensors "https://huggingface.co/numz/SeedVR2_comfyUI/resolve/main/seedvr2_ema_3b_fp16.safetensors"
命令解释:
-c
:--continue
的缩写,表示断点续传。如果下载中断,再次运行此命令可以从上次中断的地方继续。对于大文件下载,这个参数非常重要!-O seedvr2_ema_3b_fp16.safetensors
:--output-document
的缩写,指定保存的文件名。Hugging Face 的链接末尾不是直接的文件名,使用这个参数可以确保文件名正确。"..."
: 将 URL 放在引号内是一个好习惯,可以防止特殊字符导致的问题。
使用 wget 命令下载 GitHub releases 包:
wget --no-check-certificate --content-disposition https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
