Using Aria2 Download Manager

I used to download the large files with wget because I can simply resume the download tasks with -c option. This option will check the size of the output file, and download the rest of the file from the server. I can even restart the download task with a different URI. This feature is not available in many sophisticated download managers.

Recently, I came across Aria2, which is a command line download manager which supports lots of protocols, including HTTP, FTP, BitTorrents, and etc. Similar to wget, I can resume the download tasks without problems! And there are several features which are not available in wget:

  • Multiple tasks and scheduling
  • Split the download task and download the file in parallel
  • Web UI
  • ... and etc

In this post, I would like to give a brief introduction to Aria2.

Installation

Before we can start our discussion, we have to install Aria2 first.

To install Aria2 on Ubuntu (or Debian), run the following command:

$ sudo apt-get install aria2

Besides, check the file permission of your .netrc file. It should be 600, i.e. only the owner can read or write the file. You can change the file permission with following command:

$ chmod 600 ~/.netrc

Download Files with Aria2

Aria2 is similar to wget command line tool. We can simply download the files with aria2c command:

$ aria2c [URI]

For example, to download the Debian 7.8 minimal CD image:

$ aria2c http://cdimage.debian.org/debian-cd/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-netinst.iso

We can specify the output file name with -o option:

$ aria2c [URI] -o [filename]

To resume a download task, we can specify the -c option:

$ aria2c -c [URI]
$ aria2c -c [URI] -o [filename]

If we wish to download a file parallelly, we can try the -x option:

$ aria2c -x[num-parts] [URI]
$ aria2c -x2 [URI]  # Split the task into two parts.

Run Aria2 as a Daemon

If we wish to use Aria2 as a download manager, we should run Aria2 as a daemon.

To start the Aria2 daemon:

$ aria2c --enable-rpc --rpc-listen-all

By default, Aria2 will perform 5 tasks at the same time, to change the number of concurrent download tasks, we can specify the -j option:

$ aria2c --enable-rpc --rpc-listen-all -j[num-parallel]

For example, to download the files sequentially:

$ aria2c --enable-rpc --rpc-listen-all -j1

After starting the Aria2 daemon, click here for the Aria2 Web UI. You can add/remove the download tasks in the Aria2 Web UI.

Control Daemon with aria2rpc

Aria2 provides a command line tool, aria2rpc, to control the daemon. However, it is not installed by default.

To obtain aria2rpc, run the following command:

$ cat /usr/share/doc/aria2/xmlrpc/aria2rpc.gz | gzip -d > aria2rpc
$ chmod +x aria2rpc

After these steps, move aria2rpc to your $PATH, so that we can run aria2rpc directly.

Now, we can add a download task with:

$ aria2rpc addUri [URI] [options]
[task-id]

After adding a download task, an ID will be printed. We can remove a task with:

$ aria2rpc remove [task-id]

You may find more usages with:

$ aria2rpc --help