Difference between revisions of "Aria2"

From ArchWiki
Jump to: navigation, search
m (style tweaks)
m (aria2.conf)
 
(50 intermediate revisions by 21 users not shown)
Line 1: Line 1:
[[Category:Internet Applications]]
+
[[Category:Internet applications]]
 +
[[fa:Aria2]]
 
[[it:Aria2]]
 
[[it:Aria2]]
[http://aria2.sourceforge.net/ aria2] is lightweight, command-line [[Wikipedia:Download Manager|download manager]] featuring support for [[Wikipedia:HTTP|HTTP]]/[[Wikipedia:HTTPS|HTTPS]], [[Wikipedia:FTP|FTP]], [[Wikipedia:BitTorrent_(protocol)|BitTorrent]] and [[Wikipedia:Metalink|Metalink]] protocols. aria2 is generally regarded as one of the lightest and fastest download managers available and across multiple platforms. Some of the more outstanding features of aria2 include great flexibility of layout through the use of numerous options and configuration files and a built-in [[Wikipedia:XML-RPC|XML-RPC]] and [[Wikipedia:JSON-RPC|JSON-RPC]] management interface.
+
[[ja:Aria2]]
 +
[[ru:Aria2]]
 +
From the project [http://aria2.sourceforge.net/ home page]:
 +
: ''aria2 is a lightweight multi-protocol & multi-source command-line download utility. It supports [[Wikipedia:HTTP|HTTP]]/[[Wikipedia:HTTPS|HTTPS]], [[Wikipedia:FTP|FTP]], [[Wikipedia:BitTorrent_(protocol)|BitTorrent]] and [[Wikipedia:Metalink|Metalink]]. aria2 can be manipulated via built-in [[Wikipedia:JSON-RPC|JSON-RPC]] and [[Wikipedia:XML-RPC|XML-RPC]] interfaces.''
  
 
== Installation ==
 
== Installation ==
Install {{Pkg|aria2}} from [[Official Repositories|official repositories]].
 
  
You may also want to install [https://github.com/GutenYe/systemd-units/tree/master/aria2 aria2-systemd].
+
Install {{Pkg|aria2}} from [[official repositories]].
 +
 
 +
You may also want to install [https://github.com/GutenYe/systemd-units/tree/master/aria2 aria2-systemd] to use aria2 as [[daemon]].
  
 
== Execution ==
 
== Execution ==
 +
 
The executable name for the aria2 package is {{ic|aria2c}}. This legacy naming convention has been retained for backwards compatibility.
 
The executable name for the aria2 package is {{ic|aria2c}}. This legacy naming convention has been retained for backwards compatibility.
  
 
== Configuration ==
 
== Configuration ==
 +
 
=== aria2.conf ===
 
=== aria2.conf ===
aria2 looks to {{ic|~/.aria2/aria2.conf}} for a set of global configuration options by default. This behavior can be modified with the {{ic|--conf-path}} switch:
+
 
 +
aria2 looks to {{ic|$XDG_CONFIG_HOME/aria2/aria2.conf}} for a set of global configuration options by default. This behavior can be modified with the {{ic|--conf-path}} switch:
 
* Download {{ic|aria2.example.rar}} using the options specified in the configuration file {{ic|/file/aria2.rapidshare}}
 
* Download {{ic|aria2.example.rar}} using the options specified in the configuration file {{ic|/file/aria2.rapidshare}}
  $ aria2c --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar
+
  <nowiki>$ aria2c --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar</nowiki>
  
If {{ic|~/.aria2/aria2.conf}} exists and the options specified in {{ic|/file/aria2.rapidshare}} are desired, the {{ic|--no-conf}} switch must be appended to the command:
+
If {{ic|$XDG_CONFIG_HOME/aria2/aria2.conf}} exists and the options specified in {{ic|/file/aria2.rapidshare}} are desired, the {{ic|--no-conf}} switch must be appended to the command:
 
* Do not use the default configuration file and download {{ic|aria2.example.rar}} using the options specified in the configuration file {{ic|/file/aria2.rapidshare}}
 
* Do not use the default configuration file and download {{ic|aria2.example.rar}} using the options specified in the configuration file {{ic|/file/aria2.rapidshare}}
  $ aria2c --no-conf --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar
+
  <nowiki>$ aria2c --no-conf --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar</nowiki>
  
If {{ic|~/.aria2/aria2.conf}} does not yet exist and you wish to simplify the management of configuration options:
+
If {{ic|$XDG_CONFIG_HOME/aria2/aria2.conf}} does not yet exist and you wish to simplify the management of configuration options:
  $ touch ~/.aria2/aria2.conf
+
  $ touch $XDG_CONFIG_HOME/aria2/aria2.conf
  
 
=== Example .bash_alias ===
 
=== Example .bash_alias ===
Line 31: Line 39:
 
=== Example aria2.conf ===
 
=== Example aria2.conf ===
  
continue
+
{{bc|<nowiki>
dir=${HOME}/Desktop
+
continue
file-allocation=none
+
dir=${HOME}/Desktop
input-file=${HOME}/.aria2/input.conf
+
file-allocation=none
log-level=warn
+
input-file=${HOME}/.aria2/input.conf
max-connection-per-server=4
+
log-level=warn
min-split-size=5M
+
max-connection-per-server=4
on-download-complete=exit
+
min-split-size=5M
 +
on-download-complete=exit
 +
</nowiki>}}
  
 
This is essentially the same as if running the following:
 
This is essentially the same as if running the following:
Line 46: Line 56:
 
{{Note|The example aria2.conf above may incorrectly use the $HOME variable. Some users have reported the curly brace syntax to explicitly create a separate ${HOME} subdirectory in the aria2 working directory. Such a directory may be difficult to traverse as bash will consider it to be the $HOME environment variable. For now, it is recommended to use absolute path names in aria2.conf.}}
 
{{Note|The example aria2.conf above may incorrectly use the $HOME variable. Some users have reported the curly brace syntax to explicitly create a separate ${HOME} subdirectory in the aria2 working directory. Such a directory may be difficult to traverse as bash will consider it to be the $HOME environment variable. For now, it is recommended to use absolute path names in aria2.conf.}}
  
==== Option Details ====
+
==== Option details ====
 +
 
 
; {{ic|continue}}: Continue downloading a partially downloaded file if a corresponding control file exists.
 
; {{ic|continue}}: Continue downloading a partially downloaded file if a corresponding control file exists.
 
; {{ic|<nowiki>dir=${HOME}/Desktop</nowiki>}}: Store the downloaded file(s) in {{ic|~/Desktop}}.
 
; {{ic|<nowiki>dir=${HOME}/Desktop</nowiki>}}: Store the downloaded file(s) in {{ic|~/Desktop}}.
Line 56: Line 67:
 
; {{ic|<nowiki>on-download-complete=exit</nowiki>}}: Run the {{ic|exit}} command and exit the shell once the download session is complete.
 
; {{ic|<nowiki>on-download-complete=exit</nowiki>}}: Run the {{ic|exit}} command and exit the shell once the download session is complete.
  
===== Example Input File #1 =====
+
===== Example input file #1 =====
  
 
* Download {{ic|aria2-1.10.0.tar.bz2}} from two separate sources to {{ic|~/Desktop}} before merging as {{ic|aria2-1.10.0.tar.bz2}}
 
* Download {{ic|aria2-1.10.0.tar.bz2}} from two separate sources to {{ic|~/Desktop}} before merging as {{ic|aria2-1.10.0.tar.bz2}}
  http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2    http://sourceforge.net/projects/aria2/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2
+
  <nowiki>http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2    http://sourceforge.net/projects/aria2/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2</nowiki>
  
===== Example Input File #2 =====
+
===== Example input file #2 =====
  
 
* Download {{ic|aria2-1.9.5.tar.bz2}} and save to {{ic|/file/old}} as {{ic|aria2.old.tar.bz2 }} &
 
* Download {{ic|aria2-1.9.5.tar.bz2}} and save to {{ic|/file/old}} as {{ic|aria2.old.tar.bz2 }} &
 
* Download {{ic|aria2-1.10.0.tar.bz2}} and save to {{ic|~/Desktop}} as {{ic|aria2.new.tar.bz2}}
 
* Download {{ic|aria2-1.10.0.tar.bz2}} and save to {{ic|~/Desktop}} as {{ic|aria2.new.tar.bz2}}
  
  http://aria2.net/files/stable/aria2-1.9.5/aria2-1.9.5.tar.bz2
+
  <nowiki>http://aria2.net/files/stable/aria2-1.9.5/aria2-1.9.5.tar.bz2</nowiki>
 
   dir=/file/old
 
   dir=/file/old
 
   out=aria2.old.tar.bz2
 
   out=aria2.old.tar.bz2
  http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2
+
  <nowiki>http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2</nowiki>
 
   out=aria2.new.tar.bz2
 
   out=aria2.new.tar.bz2
  
==== Additional Notes ====
+
==== Additional notes ====
  
 
; <sup>1</sup> {{ic|<nowiki>--file-allocation=falloc</nowiki>}}: Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.
 
; <sup>1</sup> {{ic|<nowiki>--file-allocation=falloc</nowiki>}}: Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.
  
{{Tip|See {{ic|aria2c -help#all}} and the aria2 man page for a complete list of configuration options.}}
+
{{Tip|See {{ic|<nowiki>aria2c --help=#all</nowiki>}} and the aria2 man page for a complete list of configuration options.}}
  
 
=== Example aria2.rapidshare ===
 
=== Example aria2.rapidshare ===
  
http-user=USER_NAME
+
{{bc|<nowiki>
http-passwd=PASSWORD
+
http-user=USER_NAME
allow-overwrite=true
+
http-passwd=PASSWORD
dir=/file/Downloads
+
allow-overwrite=true
file-allocation=falloc
+
dir=/file/Downloads
enable-http-pipelining=true
+
file-allocation=falloc
input-file=/file/input.rapidshare
+
enable-http-pipelining=true
log-level=error
+
input-file=/file/input.rapidshare
max-connection-per-server=2
+
log-level=error
summary-interval=120
+
max-connection-per-server=2
 +
summary-interval=120
 +
</nowiki>}}
 +
 
 +
==== Option details ====
  
==== Option Details ====
 
 
; {{ic|<nowiki>http-user=USER_NAME</nowiki>}}: Set HTTP [[Wikipedia:User_(computing)|username]] as USER_NAME for password-protected logins. This affects all [[Wikipedia:Uniform_Resource_Identifier|URIs]].
 
; {{ic|<nowiki>http-user=USER_NAME</nowiki>}}: Set HTTP [[Wikipedia:User_(computing)|username]] as USER_NAME for password-protected logins. This affects all [[Wikipedia:Uniform_Resource_Identifier|URIs]].
 
; {{ic|<nowiki>http-passwd=PASSWORD</nowiki>}}: Set HTTP [[Wikipedia:Password|password]] as PASSWORD for password-protected logins. This affects all URIs.
 
; {{ic|<nowiki>http-passwd=PASSWORD</nowiki>}}: Set HTTP [[Wikipedia:Password|password]] as PASSWORD for password-protected logins. This affects all URIs.
Line 103: Line 117:
 
; {{ic|<nowiki>summary-interval=120</nowiki>}}: Output download progress summary every 120 seconds. (Default: 60) '''<sup>3</sup>'''
 
; {{ic|<nowiki>summary-interval=120</nowiki>}}: Output download progress summary every 120 seconds. (Default: 60) '''<sup>3</sup>'''
  
==== Additional Notes ====
+
==== Additional notes ====
  
 
* Because {{ic|aria2.rapidshare}} the contains a username and password, it is advisable to set permissions on the file to 600, or similar.
 
* Because {{ic|aria2.rapidshare}} the contains a username and password, it is advisable to set permissions on the file to 600, or similar.
  
  arch ~ $ cd /file
+
  $ cd /file
arch /file $ chmod 600 /file/aria2.rapidshare
+
  $ chmod 600 /file/aria2.rapidshare
  arch /file $ ls -l
+
  $ ls -l
 
  total 128M
 
  total 128M
 
  -rw------- 1 arch users  167 Aug 20 00:00 aria2.rapidshare
 
  -rw------- 1 arch users  167 Aug 20 00:00 aria2.rapidshare
Line 115: Line 129:
 
; '''<sup>3</sup>''' {{ic|<nowiki>summary-interval=0</nowiki>}}: Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the {{ic|log-level}} option.  
 
; '''<sup>3</sup>''' {{ic|<nowiki>summary-interval=0</nowiki>}}: Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the {{ic|log-level}} option.  
  
{{Tip|The example configuration file can also be applied to [http://www.hotfile.com/ Hotfile], [http://depositfiles.com/ DepositFiles], et.al.|}}
+
{{Tip|The example configuration file can also be applied to [http://www.hotfile.com/ Hotfile], [http://depositfiles.com/ DepositFiles], et.al.}}
{{Note|Command-line options always take precedence over options listed in a configuration file.|}}
+
{{Note|Command-line options always take precedence over options listed in a configuration file.}}
  
 
=== Example aria2.bittorrent ===
 
=== Example aria2.bittorrent ===
  
bt-seed-unverified
+
{{bc|<nowiki>
max-overall-upload-limit=1M
+
bt-seed-unverified
max-upload-limit=128K
+
max-overall-upload-limit=1M
seed-ratio=5.0
+
max-upload-limit=128K
seed-time=240
+
seed-ratio=5.0
 +
seed-time=240
 +
</nowiki>}}
 +
 
 +
==== Option details ====
  
==== Option Details ====
 
 
; {{ic|<nowiki>bt-seed-unverified=false</nowiki>}}: Do not check the hash of the file(s) before seeding. (Default: true)
 
; {{ic|<nowiki>bt-seed-unverified=false</nowiki>}}: Do not check the hash of the file(s) before seeding. (Default: true)
 
; {{ic|<nowiki>max-overall-upload-limit=1M</nowiki>}}: Set maximum overall upload speed to 1MB/sec. (Default: 0)
 
; {{ic|<nowiki>max-overall-upload-limit=1M</nowiki>}}: Set maximum overall upload speed to 1MB/sec. (Default: 0)
Line 135: Line 152:
 
{{Note|If both {{ic|seed-ratio}} and {{ic|seed-time}} are specified, seeding ends when at least one of the conditions is satisfied.}}
 
{{Note|If both {{ic|seed-ratio}} and {{ic|seed-time}} are specified, seeding ends when at least one of the conditions is satisfied.}}
  
=== Frontends ===
+
=== Example aria2.daemon ===
In order to use frontends start aria2c with {{ic|--enable-rpc}} option. Here is a list of available UIs.
+
{{Warning| Note that configurations changed using these tools are not stored.}}
+
*{{App|Diana|A command line tool|https://github.com/baskerville/diana|{{AUR|diana}}}}
+
*{{App|Webui|Html frontend|https://github.com/ziahamza/webui-aria2|}}
+
  
It is convenient to append a monitor function based on diana in your shell configuration file:
+
This configuration can be used to start Aria2 as a service. It can be used in conjunction with several of the frontends listed below. Note that rpc-user and rpc-pass are deprecated, but most frontends have not been ported to the new authentication yet. Do not forget to change user, password and Download directory.
da(){ watch -ctn 1 "(echo -e '\033[32mGID\t\t Name\t\t\t\t\t\t\t%\tDown\tSize\tSpeed\tUp\tS/L\tTime\033[36m'; diana list| cut -c -112; echo -e '\033[37m'; diana stats)" }
+
  
== Useful Tips & Tricks ==
+
{{bc|<nowiki>
 +
continue
 +
daemon=true
 +
dir=/home/aria2/Downloads
 +
file-allocation=falloc
 +
log-level=warn
 +
max-connection-per-server=4
 +
max-concurrent-downloads=3
 +
max-overall-download-limit=0
 +
min-split-size=5M
 +
enable-http-pipelining=true
  
=== pacman XferCommand ===
+
enable-rpc=true
aria2c can be used as the default download manager for the [[Pacman|pacman]] package manager. See the [[Main Page|ArchWiki]] article [[Improve_Pacman_Performance|Improve Pacman Performance]] for additional details.
+
rpc-listen-all=true
 +
rpc-user=rpcuser
 +
rpc-passwd=rpcpass
 +
</nowiki>}}
  
=== Custom Minimal Build ===
+
== Frontends ==
Gains in application response can be gleaned by removing unused features and protocols. Further gains can be accomplished by removing support for external libraries with a custom build. The following example creates an {{ic|aria2c}} executable with HTTP/HTTPS, FTP download and asynchronous DNS support only. See the [[Arch Build System]] page for further details.
+
  
==== Minimal PKGBUILD Example ====
+
{{note|Settings implemented in frontends do not affect {{ic|aria2}}'s own configuration, and it is uncertain whether the different UIs reuse {{ic|aria2}} configuration if a custom one has been made. Users should ensure their desired parameters are effectively implemented within selected tools and that they are stored persistently (uGet for example has its own {{ic|aria2}}'s command line which sticks across reboots).}}
  
{{bc|<nowiki>
+
=== Web UIs ===
pkgname=aria2
+
pkgver=1.10.0
+
pkgrel=100
+
pkgdesc="Download utility that supports HTTP(S) and FTP"
+
arch=('i686' 'x86_64')
+
url="http://aria2.sourceforge.net/"
+
license=('GPL')
+
depends=('c-ares' 'gnutls' 'zlib' 'ca-certificates')
+
source=(http://downloads.sourceforge.net/aria2/aria2-${pkgver}.tar.bz2)
+
md5sums=('1386df9b2003f42695062a0e1232e488')
+
  
build() {
+
{{Note|These frontends need {{ic|aria2c}} to be started with {{ic|--enable-rpc}} in order to work. They are meant to run on your local computer, not on a remote server that downloads using aria}}
  cd ${srcdir}/${pkgname}-${pkgver}
+
  
./configure --disable-bittorrent --disable-metalink \
+
* {{App|YaaW|Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt.|https://github.com/binux/yaaw|{{AUR|yaaw-git}}}}
--disable-dependency-tracking --disable-xmltest --disable-nls \
+
* {{App|Webui|Html frontend for aria2.|https://github.com/ziahamza/webui-aria2|{{AUR|webui-aria2}}}}
--without-sqlite3 --without-libxml2 --without-libexpat \
+
* {{App|aria2rpc|Command line tool for connecting to a remote instance of {{ic|aria2c}}. If {{ic|aria2c}} is installed it can be found under {{ic|/usr/share/doc/aria2/xmlrpc/aria2rpc}}.|https://github.com/tatsuhiro-t/aria2/blob/master/doc/xmlrpc/aria2rpc|{{Pkg|aria2}}}}
--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt --prefix=/usr
+
  
make
+
=== Other UIs ===
}
+
{{note|These frontends '''do not need''' {{ic|aria2c}} to be started with {{ic|--enable-rpc}} to function.}}
  
package() {
+
* {{App|aria2fe|A GUI for the CLI-based aria2 download utility.|http://sourceforge.net/projects/aria2fe/|{{AUR|aria2fe}}}}
cd ${srcdir}/${pkgname}-${pkgver}
+
* {{App|Diana|Command line tool for aria2|https://github.com/baskerville/diana|{{AUR|diana-git}}}}
make DESTDIR=${pkgdir} install
+
* {{App|downloadm|A download accelerator/manager which uses aria2c as a backend.|http://sourceforge.net/projects/downloadm/|{{AUR|downloadm}}{{Broken package link|{{aur-mirror|downloadm}}}}}}
 +
* {{App|eatmonkey|Download manager for Xfce that works with aria2.|http://goodies.xfce.org/projects/applications/eatmonkey|{{AUR|eatmonkey}}{{Broken package link|{{aur-mirror|eatmonkey}}}}}}
 +
* {{App|karia2|QT4 interface for aria2 download mananger.|http://sourceforge.net/projects/karia2/|{{AUR|karia2-svn}}}}
 +
* {{App|uGet|Feature-rich GTK+/CLI download manager which can use aria2 as a back-end by enabling a built-in plugin.|http://ugetdm.com|{{Pkg|uget}}}}  
 +
* {{App|yaner|GTK+ interface for aria2 download mananger.|http://iven.github.com/Yaner|{{AUR|yaner-git}}{{Broken package link|{{aur-mirror|yaner-git}}}}}}
 +
 
 +
It is convenient to append a monitor function based on diana in your shell configuration file:
 +
{{bc|<nowiki>
 +
da(){
 +
watch -ctn 1 "(echo -e '\033[32mGID\t\t Name\t\t\t\t\t\t\t%\tDown\tSize\tSpeed\tUp\tS/L\tTime\033[36m'; \
 +
diana list| cut -c -112; echo -e '\033[37m'; diana stats)"
 
}
 
}
 
</nowiki>}}
 
</nowiki>}}
  
=== aria2 sometimes stops downloading without exiting ===
+
== Tips and tricks ==
You can use this little script to restart the download every 30 minutes:
+
  
{{bc|<nowiki>
+
=== Download the packages without installing them ===
#! /bin/bash
+
  
if [ ! -x /usr/bin/aria2c ]; then
+
Just use the command below:
    echo "aria2c is not installed"
+
    exit 1
+
fi
+
  
if [ ! -d ~/.torrentdl ]; then
+
  # pacman -Sp packages | aria2c -i -
    mkdir ~/.torrentdl
+
fi
+
  
while :; do
+
{{Ic|pacman -Sp}} lists the urls of the packages on stdout, instead of downloading them, then {{Ic|<nowiki>|</nowiki>}} pipes it to the next command. Finally, The {{Ic|-i}} in {{Ic|aria2c -i -}} switch to aria2c means that the urls for files to be downloaded should be read from the file specified, but if {{Ic|-}} is passed, then read the urls from stdin.
    for i in $@; do
+
 
        MAGNET=false
+
=== pacman XferCommand ===
if [[ "$i" = magnet* ]]; then
+
 
    MAGNET=true
+
aria2 can be used as the default download manager for the [[pacman]] package manager. See the ArchWiki article [[Improve pacman performance]] for additional details.
elif [ ! -f "$i" ]; then
+
 
    echo "The file ('$i') is not given or does not exist"
+
=== Custom minimal build ===
    exit 1
+
 
fi
+
Gains in application response can be gleaned by removing unused features and protocols. Further gains can be accomplished by removing support for external libraries with a custom build. Available options are visible through {{ic|./configure --help}}. See the [[Arch Build System]] page for further details.
if ! aria2c --hash-check-only=true "$i" &> /dev/null; then
+
 
    aria2c "$i"
+
=== Start aria2c on system boot ===
    sleep 30m && kill -9 $(pidof aria2c)
+
 
else
+
{{Accuracy|Possible "failed to bind errors" indicate towards a race condition, requires/after and similar should be updated accordingly}}
    echo "Torrent is downloaded!"
+
 
fi
+
Save the following [[systemd]] service file, adjust username and config path according to your setup. Ensure your config is set to deamonize (use {{ic|1=daemon=true}}).
    done
+
 
done
+
{{hc|/etc/systemd/system/aria2c.service|<nowiki>
 +
[Unit]
 +
Description=Aria2c download manager
 +
After=network.target
 +
 
 +
[Service]
 +
User=aria2
 +
Type=forking
 +
ExecStart=/usr/bin/aria2c --conf-path=/home/aria2/.aria2/aria2.daemon
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 
</nowiki>}}
 
</nowiki>}}
 +
 +
Then [[systemd#Using units|start and/or enable]] the service.
 +
 +
=== Changing the User Agent ===
 +
 +
Some sites may filter the requests based on your User Agent, since Aria2 is not a well known downloader, it may be good to use a most known downloader or browser as the Aria's User Agent. Just use the -U option like this:
 +
 +
$ aria2c -UWget <nowiki>http://some-url-to-download/file.xyz</nowiki>
 +
 +
You can use whatever you want, like '''-UMozilla/5.0''' and so on.
 +
 +
=== Using Aria2 with makepkg ===
 +
 +
You can use [[Aria2]] instead of curl to download source files, just change the {{ic|DLAGENTS}} variable as follows:
 +
 +
{{hc|/etc/makepkg.conf|2=
 +
[...]
 +
DLAGENTS=('ftp::/usr/bin/aria2c -UWget -s4 %u -o %o'
 +
          'http::/usr/bin/aria2c -UWget -s4 %u -o %o'
 +
          'https::/usr/bin/aria2c -UWget -s4 %u -o %o'
 +
          'rsync::/usr/bin/rsync -z %u %o'
 +
          'scp::/usr/bin/scp -C %u %o')
 +
[...]
 +
}}
 +
 +
{{Note|Use the {{ic|-UWget}} option to change the user agent to Wget. It may prevent problems when downloading from sites that filters the requests based on the user agent to provide different responses on what the users uses to access the URL. Since Aria2 is a lesser known downloader it may be recognized by the site as a browser instead of a downloader, so changing the user agent to Wget may fix it in most cases}}
  
 
== See also ==
 
== See also ==
* [http://sourceforge.net/apps/trac/aria2/wiki aria2 Wiki] - Official Site
+
 
* [http://sourceforge.net/apps/trac/aria2/wiki/UsageExample aria2 Usage Examples] - Official Site
+
* [http://sourceforge.net/apps/trac/aria2/wiki aria2 wiki] - Official site
* [http://gotux.net/arch-linux/aria2c-downloader-through-vpn-tunnel/ Aria2c Downloader through VPN Tunnel] - UnOfficial Site
+
* [http://sourceforge.net/apps/trac/aria2/wiki/UsageExample aria2 usage examples] - Official site
 +
* [http://gotux.net/arch-linux/aria2c-downloader-through-vpn-tunnel/ aria2c downloader through VPN tunnel] - Unofficial site

Latest revision as of 08:51, 8 February 2016

From the project home page:

aria2 is a lightweight multi-protocol & multi-source command-line download utility. It supports HTTP/HTTPS, FTP, BitTorrent and Metalink. aria2 can be manipulated via built-in JSON-RPC and XML-RPC interfaces.

Installation

Install aria2 from official repositories.

You may also want to install aria2-systemd to use aria2 as daemon.

Execution

The executable name for the aria2 package is aria2c. This legacy naming convention has been retained for backwards compatibility.

Configuration

aria2.conf

aria2 looks to $XDG_CONFIG_HOME/aria2/aria2.conf for a set of global configuration options by default. This behavior can be modified with the --conf-path switch:

  • Download aria2.example.rar using the options specified in the configuration file /file/aria2.rapidshare
$ aria2c --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar

If $XDG_CONFIG_HOME/aria2/aria2.conf exists and the options specified in /file/aria2.rapidshare are desired, the --no-conf switch must be appended to the command:

  • Do not use the default configuration file and download aria2.example.rar using the options specified in the configuration file /file/aria2.rapidshare
$ aria2c --no-conf --conf-path=/file/aria2.rapidshare http://rapidshare.com/files/12345678/aria2.example.rar

If $XDG_CONFIG_HOME/aria2/aria2.conf does not yet exist and you wish to simplify the management of configuration options:

$ touch $XDG_CONFIG_HOME/aria2/aria2.conf

Example .bash_alias

alias down='aria2c --conf-path=${HOME}/.aria2/aria2.conf'
alias rapid='aria2c --conf-path=/file/aria2.rapidshare'

Example aria2.conf

continue
dir=${HOME}/Desktop
file-allocation=none
input-file=${HOME}/.aria2/input.conf
log-level=warn
max-connection-per-server=4
min-split-size=5M
on-download-complete=exit

This is essentially the same as if running the following:

$ aria2c dir=${HOME}/Desktop file-allocation=none input-file=${HOME}/.aria2/input.conf on-download-complete=exit log-level=warn FILE
Note: The example aria2.conf above may incorrectly use the $HOME variable. Some users have reported the curly brace syntax to explicitly create a separate ${HOME} subdirectory in the aria2 working directory. Such a directory may be difficult to traverse as bash will consider it to be the $HOME environment variable. For now, it is recommended to use absolute path names in aria2.conf.

Option details

continue
Continue downloading a partially downloaded file if a corresponding control file exists.
dir=${HOME}/Desktop
Store the downloaded file(s) in ~/Desktop.
file-allocation=none
Do not pre-allocate disk space before downloading begins. (Default: prealloc) 1
input-file=${HOME}/.aria2/input.conf
Download a list of line, or TAB separated URIs found in ~/.aria2/input.conf
log-level=warn
Set log level to output warnings and errors only. (Default: debug)
max-connection-per-server=4
Set a maximum of four (4) connections to each server per file. (Default: 1)
min-split-size=5M
Only split the file if the size is larger than 2*5MB = 10MB. (Default: 20M)
on-download-complete=exit
Run the exit command and exit the shell once the download session is complete.
Example input file #1
  • Download aria2-1.10.0.tar.bz2 from two separate sources to ~/Desktop before merging as aria2-1.10.0.tar.bz2
http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2    http://sourceforge.net/projects/aria2/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2
Example input file #2
  • Download aria2-1.9.5.tar.bz2 and save to /file/old as aria2.old.tar.bz2 &
  • Download aria2-1.10.0.tar.bz2 and save to ~/Desktop as aria2.new.tar.bz2
http://aria2.net/files/stable/aria2-1.9.5/aria2-1.9.5.tar.bz2
  dir=/file/old
  out=aria2.old.tar.bz2
http://aria2.net/files/stable/aria2-1.10.0/aria2-1.10.0.tar.bz2
  out=aria2.new.tar.bz2

Additional notes

1 --file-allocation=falloc
Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.
Tip: See aria2c --help=#all and the aria2 man page for a complete list of configuration options.

Example aria2.rapidshare

http-user=USER_NAME
http-passwd=PASSWORD
allow-overwrite=true
dir=/file/Downloads
file-allocation=falloc
enable-http-pipelining=true
input-file=/file/input.rapidshare
log-level=error
max-connection-per-server=2
summary-interval=120

Option details

http-user=USER_NAME
Set HTTP username as USER_NAME for password-protected logins. This affects all URIs.
http-passwd=PASSWORD
Set HTTP password as PASSWORD for password-protected logins. This affects all URIs.
allow-overwrite=true
Restart download if a corresponding control file does not exist. (Default: false)
dir=/file/Downloads
Store the downloaded file(s) in /file/Downloads.
file-allocation=falloc
Call posix_fallocate() to allocate disk space before downloading begins. (Default: prealloc)
enable-http-pipelining=true
Enable HTTP/1.1 pipelining to overcome network latency and to reduce network load. (Default: false)
input-file=/file/input.rapidshare
Download a list of single line of TAB separated URIs found in /file/input.rapidshare
log-level=error
Set log level to output errors only. (Default: debug)
max-connection-per-server=2
Set a maximum of two (2) connections to each server per file. (Default: 1)
summary-interval=120
Output download progress summary every 120 seconds. (Default: 60) 3

Additional notes

  • Because aria2.rapidshare the contains a username and password, it is advisable to set permissions on the file to 600, or similar.
$ cd /file
$ chmod 600 /file/aria2.rapidshare
$ ls -l
total 128M
-rw------- 1 arch users  167 Aug 20 00:00 aria2.rapidshare
3 summary-interval=0
Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the log-level option.
Tip: The example configuration file can also be applied to Hotfile, DepositFiles, et.al.
Note: Command-line options always take precedence over options listed in a configuration file.

Example aria2.bittorrent

bt-seed-unverified
max-overall-upload-limit=1M
max-upload-limit=128K
seed-ratio=5.0
seed-time=240

Option details

bt-seed-unverified=false
Do not check the hash of the file(s) before seeding. (Default: true)
max-overall-upload-limit=1M
Set maximum overall upload speed to 1MB/sec. (Default: 0)
max-upload-limit=128K
Set maximum upload speed per torrent to 128K/sec. (Default: 0)
seed-ratio=5.0
Seed completed torrents until share ratio reaches 5.0. (Default: 1.0)
seed-time=240
Seed completed torrents for 240 minutes.
Note: If both seed-ratio and seed-time are specified, seeding ends when at least one of the conditions is satisfied.

Example aria2.daemon

This configuration can be used to start Aria2 as a service. It can be used in conjunction with several of the frontends listed below. Note that rpc-user and rpc-pass are deprecated, but most frontends have not been ported to the new authentication yet. Do not forget to change user, password and Download directory.

continue
daemon=true
dir=/home/aria2/Downloads
file-allocation=falloc
log-level=warn
max-connection-per-server=4
max-concurrent-downloads=3
max-overall-download-limit=0
min-split-size=5M
enable-http-pipelining=true

enable-rpc=true
rpc-listen-all=true
rpc-user=rpcuser
rpc-passwd=rpcpass

Frontends

Note: Settings implemented in frontends do not affect aria2's own configuration, and it is uncertain whether the different UIs reuse aria2 configuration if a custom one has been made. Users should ensure their desired parameters are effectively implemented within selected tools and that they are stored persistently (uGet for example has its own aria2's command line which sticks across reboots).

Web UIs

Note: These frontends need aria2c to be started with --enable-rpc in order to work. They are meant to run on your local computer, not on a remote server that downloads using aria
  • YaaW — Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt.
https://github.com/binux/yaaw || yaaw-gitAUR
  • Webui — Html frontend for aria2.
https://github.com/ziahamza/webui-aria2 || webui-aria2AUR
  • aria2rpc — Command line tool for connecting to a remote instance of aria2c. If aria2c is installed it can be found under /usr/share/doc/aria2/xmlrpc/aria2rpc.
https://github.com/tatsuhiro-t/aria2/blob/master/doc/xmlrpc/aria2rpc || aria2

Other UIs

Note: These frontends do not need aria2c to be started with --enable-rpc to function.
  • aria2fe — A GUI for the CLI-based aria2 download utility.
http://sourceforge.net/projects/aria2fe/ || aria2feAUR
  • Diana — Command line tool for aria2
https://github.com/baskerville/diana || diana-gitAUR
  • downloadm — A download accelerator/manager which uses aria2c as a backend.
http://sourceforge.net/projects/downloadm/ || downloadmAUR[broken link: archived in aur-mirror]
  • eatmonkey — Download manager for Xfce that works with aria2.
http://goodies.xfce.org/projects/applications/eatmonkey || eatmonkeyAUR[broken link: archived in aur-mirror]
  • karia2 — QT4 interface for aria2 download mananger.
http://sourceforge.net/projects/karia2/ || karia2-svnAUR
  • uGet — Feature-rich GTK+/CLI download manager which can use aria2 as a back-end by enabling a built-in plugin.
http://ugetdm.com || uget
  • yaner — GTK+ interface for aria2 download mananger.
http://iven.github.com/Yaner || yaner-gitAUR[broken link: archived in aur-mirror]

It is convenient to append a monitor function based on diana in your shell configuration file:

da(){
watch -ctn 1 "(echo -e '\033[32mGID\t\t Name\t\t\t\t\t\t\t%\tDown\tSize\tSpeed\tUp\tS/L\tTime\033[36m'; \
diana list| cut -c -112; echo -e '\033[37m'; diana stats)"
}

Tips and tricks

Download the packages without installing them

Just use the command below:

 # pacman -Sp packages | aria2c -i -

pacman -Sp lists the urls of the packages on stdout, instead of downloading them, then | pipes it to the next command. Finally, The -i in aria2c -i - switch to aria2c means that the urls for files to be downloaded should be read from the file specified, but if - is passed, then read the urls from stdin.

pacman XferCommand

aria2 can be used as the default download manager for the pacman package manager. See the ArchWiki article Improve pacman performance for additional details.

Custom minimal build

Gains in application response can be gleaned by removing unused features and protocols. Further gains can be accomplished by removing support for external libraries with a custom build. Available options are visible through ./configure --help. See the Arch Build System page for further details.

Start aria2c on system boot

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Possible "failed to bind errors" indicate towards a race condition, requires/after and similar should be updated accordingly (Discuss in Talk:Aria2#)

Save the following systemd service file, adjust username and config path according to your setup. Ensure your config is set to deamonize (use daemon=true).

/etc/systemd/system/aria2c.service
[Unit]
Description=Aria2c download manager
After=network.target

[Service]
User=aria2
Type=forking
ExecStart=/usr/bin/aria2c --conf-path=/home/aria2/.aria2/aria2.daemon

[Install]
WantedBy=multi-user.target

Then start and/or enable the service.

Changing the User Agent

Some sites may filter the requests based on your User Agent, since Aria2 is not a well known downloader, it may be good to use a most known downloader or browser as the Aria's User Agent. Just use the -U option like this:

$ aria2c -UWget http://some-url-to-download/file.xyz

You can use whatever you want, like -UMozilla/5.0 and so on.

Using Aria2 with makepkg

You can use Aria2 instead of curl to download source files, just change the DLAGENTS variable as follows:

/etc/makepkg.conf
[...]
DLAGENTS=('ftp::/usr/bin/aria2c -UWget -s4 %u -o %o'
          'http::/usr/bin/aria2c -UWget -s4 %u -o %o'
          'https::/usr/bin/aria2c -UWget -s4 %u -o %o'
          'rsync::/usr/bin/rsync -z %u %o'
          'scp::/usr/bin/scp -C %u %o')
[...]
Note: Use the -UWget option to change the user agent to Wget. It may prevent problems when downloading from sites that filters the requests based on the user agent to provide different responses on what the users uses to access the URL. Since Aria2 is a lesser known downloader it may be recognized by the site as a browser instead of a downloader, so changing the user agent to Wget may fix it in most cases

See also