aria2 – A Command Line Multi-Protocol Download Tool for Linux

aria2 is a free, open source, lightweight multi-protocol and multi-source command-line download application.

It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.

‘aria2’ can be manipulated via built-in JSON-RPC and XML-RPC interfaces.

aria2 automatically checks chunks of the data when downloading a file.

It can download a file from multiple sources/protocols and tries to utilize maximum download bandwidth.

By default all the Linux Distributions include ‘aria2’, so you can install it easily from the official repository.

Some GUI Download Manager also use aria2 as a plugin to improve the download speeds, such as Uget Download Manager.

Aria2 Features

  • HTTP/HTTPS GET support
  • HTTP Proxy support
  • HTTP BASIC authentication support
  • HTTP Proxy authentication support
  • FTP support(active, passive mode)
  • FTP through HTTP proxy(GET command or tunneling)
  • Segmented download
  • Cookie support
  • It can run as a daemon process.
  • Multi-Connection Download.
  • BitTorrent protocol support with fast extension.
  • Selective download in multi-file torrent
  • Metalink version 3.0 support(HTTP/FTP/BitTorrent).
  • Limiting download/upload speed

1) How to Install ‘aria2’ on Linux

The ‘aria2’ command line download utility can be easily installed on all Linux distributions such as Debian, Ubuntu, Red Hat (RHEL), CentOS, Fedora, suse, openSUSE, and ArchLinux, from the official distribution repository.

For CentOS and RHEL systems you must enable the EPEL Repository in order to install the ‘aria2’ package.

For Fedora, RHEL 8 and CentOS 8 systems, use the DNF Command to install ‘aria2’:

$ sudo dnf install aria2

For Debian/Ubuntu systems, use APT-GET Command or APT Command to install ‘aria2’:

$ sudo apt install aria2

For Arch Linux based systems, use Pacman Command to install ‘aria2’:

$ sudo pacman -S aria2

For RHEL/CentOS 6/7 systems, use YUM Command to install ‘aria2’:

$ sudo yum install aria2

For openSUSE system, use Zypper Command to install ‘aria2’:

$ sudo zypper install aria2

2) How to Download Single File Using aria2 Command

The following command will download the file from the given URL and stores the file in the current directory. When you download the file, you will see the date, time, download speed and download progress of file.

# aria2c https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#986c80 19MiB/21MiB(90%) CN:1 DL:3.0MiB]
03/22 09:49:13 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
986c80|OK  |   3.0MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

3) How to Save a File with a Different Name Using aria2 Command

A file can be saved with a different name and format when starting the download using the -o (lowercase) option. In our example below, we are going to save the file as owncloud.zip.

# aria2c -o owncloud.zip https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#d31304 16MiB/21MiB(74%) CN:1 DL:6.2MiB]
03/22 09:51:02 [NOTICE] Download complete: /opt/owncloud.zip

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
d31304|OK  |   7.3MiB/s|/opt/owncloud.zip

Status Legend:
(OK):download completed.

4) How to Limit Download Speed Using ‘aria2’ Command

By default ‘aria2’ uses the full bandwidth to download a file, and if the Internet is slow you will not be able to parallelly use other functions on the server, so use the –max-download-limit option to avoid this issue. In our example below, we have limited the download size to 500K:

# aria2c --max-download-limit=500k https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#7f9fbf 21MiB/21MiB(99%) CN:1 DL:466KiB]
03/22 09:54:51 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
7f9fbf|OK  |   462KiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

5) How to Download Multiple Files at Once Using the ‘aria2’ Command

The following command will download two files from the given links, and save them in the current directory, where you will find the information such as date, time, download speed and download progress while downloading the file.

# aria2c "https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2" "https://download.owncloud.org/community/owncloud-10.5.tar.bz2"
[DL:1.7MiB][#53533c 272KiB/21MiB(1%)][#b52bb1 768KiB/3.6MiB(20%)]
03/22 10:25:54 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2
[#53533c 18MiB/21MiB(86%) CN:1 DL:3.2MiB]
03/22 10:25:59 [NOTICE] Download complete: /opt/owncloud-9.0.0.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
b52bb1|OK  |   3.8MiB/s|/opt/owncloud-10.5.tar.bz2
53533c|OK  |   3.4MiB/s|/opt/owncloud-9.0.0.tar.bz2

Status Legend:
(OK):download completed.

Here is an example to download a file from HTTP and FTP servers at the same time:

# aria2c "https://download.owncloud.org/community/owncloud-10.5.tar.bz2" "ftp://ftp.gnu.org/gnu/wget/wget-1.17.tar.gz"
[DL:1.7MiB][#53533c 272KiB/21MiB(1%)][#b52bb1 768KiB/3.6MiB(20%)]
03/22 10:25:54 [NOTICE] Download complete: /opt/wget-1.17.tar.gz
[#53533c 18MiB/21MiB(86%) CN:1 DL:3.2MiB]
03/22 10:25:59 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
b52bb1|OK  |   2.8MiB/s|/opt/wget-1.17.tar.gz
53533c|OK  |   3.4MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

6) How to Resume an Incomplete Download Using the aria2 Command

Whenever you download a large file (eg ISO images), I advise you to add the -c option to the command. It will help you to resume the incomplete download from where it stopped and finish it off as usual. This is seen when you have any network connection issue or system issues.

Otherwise, when you download it again, it will start a new download and save it with a different file name (automatically appends”1″ to the file name).

# aria2c -c https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#db0b08 8.2MiB/21MiB(38%) CN:1 DL:3.1MiB ETA:4s]^C
03/22 10:09:26 [NOTICE] Shutdown sequence commencing... Press Ctrl-C again for emergency shutdown.

03/22 10:09:26 [NOTICE] Download GID#db0b08bf55d5908d not complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
db0b08|INPR|   3.3MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(INPR):download in-progress.

aria2 will resume download if the transfer is restarted.

# aria2c -c https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#873d08 21MiB/21MiB(98%) CN:1 DL:2.7MiB]
03/22 10:09:57 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
873d08|OK  |   1.9MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

7) How to Download Files in Bulk Using the aria2 Command

Note: In case of any interruption, ‘area2’ saves the current file with the extension .aria2 :

Alternatively ‘aria2’ can get a list of input URLs from a file and download them. To do so, you need to create a file and save each URL in a separate line. Add the -i option to the aria2 command to perform this operation as shown in the example below:

# aria2c -i test-aria2.txt
[DL:3.9MiB][#b97984 192KiB/21MiB(0%)][#673c8e 2.5MiB/3.6MiB(69%)]
03/22 10:14:22 [NOTICE] Download complete: /opt/wget-1.17.tar.gz
[#b97984 19MiB/21MiB(90%) CN:1 DL:2.5MiB]
03/22 10:14:30 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
673c8e|OK  |   4.3MiB/s|/opt/wget-1.17.tar.gz
b97984|OK  |   2.5MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

If you want to download multiple files, you can use multiple connections with the “-x” option as shown below:

# aria2c -i test-aria2.txt -x2 -k1M

Note: The -x option specifies the number of allowed connections, while the -k option specifies the size of chunks.

8) How to Download a File Using Multiple Connections

By default aria2 will establish one connection to each host when downloading a file. You can establish more than one connection to each host in order to speedup the downloads by adding -x option with ‘aria2’ command.

I have included -x5 connections in this example download below:

# aria2c -x5 https://download.owncloud.org/community/owncloud-10.5.tar.bz2
[#ddd4cd 18MiB/21MiB(83%) CN:1 DL:5.0MiB]
03/22 10:16:27 [NOTICE] Download complete: /opt/owncloud-10.5.tar.bz2

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
ddd4cd|OK  |   5.5MiB/s|/opt/owncloud-10.5.tar.bz2

Status Legend:
(OK):download completed.

9) How to Download a Torrent File Using the aria2 Command

The following command will download a file from the given torrent URL, and stores it in the current directory and when you download the file you will see the date, time, download speed and download progress of the file:

# aria2c https://torcache.net/torrent/C86F4E743253E0EBF3090CCFFCC9B56FA38451A3.torrent?title=[kat.cr]irudhi.suttru.2015.official.teaser.full.hd.1080p.pathi.team.sr
[#388321 0B/0B CN:1 DL:0B]                                                                                                                    
03/22 20:06:14 [NOTICE] Download complete: /opt/[kat.cr]irudhi.suttru.2015.official.teaser.full.hd.1080p.pathi.team.sr.torrent

03/22 20:06:14 [ERROR] Exception caught
Exception: [BtPostDownloadHandler.cc:98] errorCode=25 Could not parse BitTorrent metainfo

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
388321|OK  |    11MiB/s|/opt/[kat.cr]irudhi.suttru.2015.official.teaser.full.hd.1080p.pathi.team.sr.torrent

Status Legend:
(OK):download completed.

Download using a local torrent file:

# aria2c file.torrent

10) How to Download BitTorrent Magnet URI Using aria2 Command

You can download a torrent file directly via the BitTorrent Magnet URI using the aria2 command as follows.

Make a note: Don’t forget to use single(‘) or double(“) quotes with BitTorrent Magnet URIs which includes “&” character.

# aria2c 'magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C'

11) How to Download BitTorrent Metalink Using aria2 Command

You can also download the Metalink file directly using the aria2 command as shown below:

# aria2c https://curl.haxx.se/metalink.cgi?curl=tar.bz2

12) How to Download a File from Password Protected Sites (Proxy with Authorization)

You can download a file from password protected sites using the aria2 command. To do so, use the following format:

# aria2c --http-proxy="http://username:password@proxy:8080" "https://download.owncloud.org/community/owncloud-10.5.tar.bz2"
or
# aria2c --http-proxy="http://proxy:8080" --http-proxy-user="username" --http-proxy-passwd="password" "https://download.owncloud.org/community/owncloud-10.5.tar.bz2"

13) aria2 Man Page

If you want to know the additional options for ‘aria2’ command, you can always get the details from its man page:

# man aria2c
or
# aria2c --help

Wrapping Up

In this article, we have shown you several examples to download a file using the ‘aria2’ command in Linux.

If you have any questions or feedback, feel free to comment below and we will get back to you as soon as possible. Happy Learning!

Ref: aria2 examples

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

6 Comments on “aria2 – A Command Line Multi-Protocol Download Tool for Linux”

  1. I use aria2 for more than a decade for my downloads. The best GUI is not Uget but Persepolis which also has windows version and a firefox extension to catch links directly from the browser. Try it and you won’t regret it. Persepolis is QT based though. For me its ok since I use KDE plasma anyway. Aria2 is by far the fastest download manager I have ever seen.

  2. Hi, may I know how to download from a local torrent file instead? I already have the .torrent file on my hard disk.

Leave a Reply

Your email address will not be published. Required fields are marked *