Axel 是一個輕量級下載程序,它和其他加速器一樣,對同一個文件建立多個連接,每個連接下載單獨的文件片段以更快地完成下載。Axel 支持 HTTP、HTTPS、FTP 和 FTPS 協議。它也可以使用多個鏡像站點下載單個文件,所以,Axel 可以加速下載高達 40%(大約,我個人認為)。它非常輕量級,因為它沒有依賴並且使用非常少的 CPU 和內存。Axel 一步到位地將所有數據直接下載到目標文件(LCTT 譯註:而不是像其它的下載軟體那樣下載成多個文件塊,然後拼接)。注意:不支持在單條命令中下載兩個文件。
大多數發行版(Debian、Ubuntu、Mint、Fedora、suse、openSUSE、Arch Linux、Manjaro、Mageia 等)都有 axel 包,所以我們可以從發行版官方倉庫輕鬆安裝。對於 CentOS/RHEL,我們需要啟用 EPEL Repository。
[在 Debian/Ubuntu/LinuxMint 上安裝 Axel]
$ sudo apt-get install axel
[在 RHEL/CentOS 上安裝 Axel]
$ sudo yum install axel
[在 Fedora 上安裝 Axel]
$ sudo dnf install axel
[在 openSUSE 上安裝 Axel]
$ sudo zypper install axel
[在 Mageia 上安裝 Axel]
$ sudo urpmi axel
[在基於 Arch Linux 的發行版安裝 Axel]
$ sudo pacman -S axel
1) 下載單個文件。以下命令將從給定的 URL 下載文件並存儲在當前目錄中,下載文件時,我們可以看到文件的信息(建立的連接數、下載速度、下載進度、完成下載所花費的時間以及連接完成的時間)。
# axel https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
[ 0%] .......... .......... .......... .......... .......... [ 146.7KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 267.0KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 373.9KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 406.9KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 487.5KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 572.6KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 650.7KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 649.3KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 718.1KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 769.3KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 838.7KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 866.0KB/s]
Connection 0 finished
.
.
[ 99%] .......... .......... .......... .......... .......... [5721.0KB/s]
Connection 2 finished
[ 99%] .......... .......... .......... .......... .......... [5733.4KB/s]
Connection 1 finished
[ 99%] .......... .......... .......... .......... .......... [5745.4KB/s]
[100%] .......... .......... .......... .......... ......
Downloaded 21.6 megabytes in 3 seconds. (5755.94 KB/s)
2) 用不同的名稱保存文件。要使用其他名稱來保存文件,啟動下載時可以添加 -o(小寫字母)選項和文件名。這裡我們使用文件名 owncloud.tar.bz2 來保存文件。
# axel -o cloud.tar.bz2 https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file cloud.tar.bz2
Starting download
[ 0%] .......... .......... .......... .......... .......... [ 143.0KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 264.1KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 309.8KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 406.3KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 495.4KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 586.3KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 673.1KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 647.1KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 721.1KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 781.3KB/s]
Connection 2 finished
.
.
Connection 0 finished
[ 98%] .......... .......... .......... .......... .......... [6221.9KB/s]
[ 98%] .......... .......... .....
Connection 1 finished
,,,,,,,,,, ,,,,,,,,,, ,,,,,..... .......... .......... [6145.6KB/s]
[ 99%] .......... .......... .......... .......... .......... [6159.2KB/s]
[ 99%] .......... .......... .......... .......... .......... [6172.0KB/s]
[ 99%] .......... .......... .......... .......... .......... [5977.9KB/s]
[ 99%] .......... .......... .......... .......... .......... [5989.6KB/s]
[100%] .......... .......... .......... .......... ......
Downloaded 21.6 megabytes in 3 seconds. (6001.05 KB/s)
3) 限制下載速度。默認情況下 axel 以位元組/秒為單位設置下載文件的最大速度。當我們的網路連接速度較慢時,可以使用此選項。只需添加 -s 選項,後面跟位元組值。這裡我們要限速 512 KB/s 下載一個文件。
# axel -s 512000 https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
[ 0%] .......... .......... .......... .......... .......... [ 141.5KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 266.1KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 308.0KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 405.9KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 496.7KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 526.4KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 507.0KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 505.6KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 504.8KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 503.9KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 503.4KB/s]
.
.
[ 99%] .......... .......... .......... .......... .......... [ 497.0KB/s]
[ 99%] .......... .......... .......... .......... .......... [ 496.9KB/s]
[100%] .......... ..
Connection 0 finished
,,,,,,,,,, ,,.....
Connection 1 finished
Connection 3 finished
,,,,,,,,,, ,,,,,,,... .......... .......... ......
Downloaded 21.6 megabytes in 44 seconds. (494.54 KB/s)
4) 限制連接數。axel 默認建立 4 個連接以從不同的鏡像獲取文件。此外,我們可以通過使用 -n 選項添加更多的連接,後跟連接數 10 來提高下載速度。保險起見,我們添加了十個連接,但不幸的是,它花了更多時間來下載文件。
# axel -n 10 https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
[ 0%] .......... .......... .......... .......... .......... [ 140.8KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 265.7KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 305.4KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 402.1KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 496.3KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 522.1KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 567.5KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 640.5KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 710.8KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 780.5KB/s]
.
.
[ 98%] .......... .......... .......... .......... .......... [7544.9KB/s]
[ 98%] .......... .......... .......... .......... .......... [7557.9KB/s]
[ 98%] .......... .......... .......... .......... .......... [7570.4KB/s]
[ 98%] .......... .......... .......... .......... .......... [7495.3KB/s]
[ 99%] .......... .......... .......... .......... ......
Connection 2 finished
,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,.... [7311.6KB/s]
[ 99%] .......... .......... .......... .......... .......... [7318.9KB/s]
[ 99%] .......... .......... .......... .......... ..........
Connection 9 finished
,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, [7331.0KB/s]
[ 99%] .......... .......... .......... ..........
Connection 3 finished
,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, .......... [4300.7KB/s]
[100%] .......... .......... .......... .......... ......
Downloaded 21.6 megabytes in 5 seconds. (4109.41 KB/s)
5) 恢復未完成的下載。axel 默認具有恢復未完成的下載的行為。Axel 在下載文件時定期更新狀態文件(擴展名為 .st)。由於某些原因,下載中途停止了?不用擔心,只要使用相同的 axel 命令,它將會檢查 file 和 file.st,如果找到,它會從停止處恢復下載。
# axel https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
[ 0%] .......... .......... .......... .......... .......... [ 140.8KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 265.7KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 305.4KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 402.1KB/s]
[ 0%] .......... .......... .......... .......... .......... [ 496.3KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 522.1KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 567.5KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 640.5KB/s]
[ 1%] .......... .......... .......... .......... .......... [ 710.8KB/s]
[ 2%] .......... .......... .......... .......... .......... [ 780.5KB/s]
.
.
[ 84%] .......... .......... .......... .......... .......... [7100.7KB/s]
[ 84%] .......... .......... .......... .......... .......... [7104.3KB/s]
[ 84%] .......... .......... .......... .^C
Downloaded 18.3 megabytes in 2 seconds. (7009.79 KB/s)
上面的輸出清晰地顯示了在下載斷開時有兩個文件 owncloud-9.0.0.tar.bz2 和 owncloud-9.0.0.tar.bz2.st。當重新開始下載時,它會從停止處開始下載。
# ls -lh
total 19M
-rw------- 1 root root 22M Dec 27 08:33 owncloud-9.0.0.tar.bz2
-rw------- 1 root root 44 Dec 27 08:33 owncloud-9.0.0.tar.bz2.st
# axel https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
State file found: 19180828 bytes downloaded, 3497380 to go.
Starting download
,,,,,,,,,, ,,,,,,,,,, ,,,,,,,,,, ,......... .......... [ 66.5KB/s]
[ 84%] .......... .......... .......... .......... .......... [ 186.0KB/s]
[ 85%] .......... .......... .......... .......... .......... [ 241.7KB/s]
[ 85%] .......... .......... .......... .......... .......... [ 335.6KB/s]
[ 85%] .......... .......... .......... .......... .......... [ 351.5KB/s]
[ 85%] .......... .......... .......... .......... .......... [ 427.1KB/s]
[ 85%] .......... .......... .......... .......... .......... [ 427.4KB/s]
[ 86%] .......... .......... .......... .......... .......... [ 491.5KB/s]
.
.
[ 98%] ...
Connection 0 finished
,,,....... .......... .......... .......... .......... [2106.6KB/s]
[ 99%] .......... .......... .......... .......... .......... [2140.5KB/s]
[ 99%] .......... .......... .......... .......... .......... [2172.4KB/s]
[ 99%] .......... .......... .......... .......... .......... [2203.2KB/s]
[ 99%] .......... .......... .......... .......... .......... [2236.2KB/s]
[100%] .......... .......... .......... .......... ......
Downloaded 3415.4 kilobytes in 1 second. (2264.93 KB/s)
6) 不顯示文件下載進度。如果你不想要看到文件的下載進度,只要在 axel 命令中加入 -q 選項。
# axel -q https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
7) 替換進度條。如果你不喜歡默認的進度條,你可以使用 -a 選項來替換進度條。
# axel -a https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
Initializing download: https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
[ 66%] [......0 ...1 ..........2 ...........3] [ 5.8MB/s] [00:01]^C
Downloaded 14.3 megabytes in 2 seconds. (5916.11 KB/s)
我們中斷了上面的下載,以便在下載文件時能清楚地顯示替代進度條狀態。一旦文件成功下載後,你可以看到相同的輸出,如下所示。
# axel -a https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
File size: 22678208 bytes
Opening output file owncloud-9.0.0.tar.bz2
Starting download
Connection 2 finished ]
Connection 1 finished ]
Connection 3 finished ]
Connection 0 finished ]
Downloaded 21.6 megabytes in 4 seconds. (5062.32 KB/s)
8) 了解關於 axel 的更多信息。如果你想要了解更多關於 axel 的選項,只需要進入它的手冊。
# man axel
或者
# axel --help