How to Use the Command 'aria2c' (with Examples)
Aria2c is a robust, multi-protocol command-line download utility designed to facilitate fast and efficient file downloads. It supports a wide range of protocols, including HTTP(S), FTP, SFTP, BitTorrent, and Metalink, broadening your downloading capabilities. Known for its speed and simplicity, it allows users to handle multiple downloads simultaneously or optimize through parallel connections, while providing advanced features like checksum verification and download speed limits.
Download a Specific URI to a File
Code:
aria2c "url"
Motivation: This is the most straightforward use of the aria2c command, ideal for when you need to download a file directly from a single URL. It’s particularly useful for single, quick downloads where you don’t require any customization or additional options.
Explanation:
aria2c
: Invokes the aria2c command line utility."url"
: Specifies the URL of the file you wish to download.
Example Output: Upon successful execution, the output may look something like this:
[#1 SIZE:1.4MiB/1.4MiB(100%) CN:1 DL:958KiB ETA:0s]
Download completed: /path/to/downloaded/file
Download a File from a URI with a Specific Output Name
Code:
aria2c --out path/to/file "url"
Motivation: Sometimes, the default file name derived from the URL might not be intuitive or doesn’t fit your organizational needs. This command lets you specify exactly where and under what name the file should be saved, which can help in maintaining a well-organized download directory.
Explanation:
aria2c
: Invokes the aria2c command line utility.--out path/to/file
: Specifies the path and name you want for the downloaded file."url"
: Specifies the URL of the file you are downloading.
Example Output:
[#1 SIZE:1.4MiB/1.4MiB(100%) CN:1 DL:932KiB ETA:0s]
Download completed: path/to/file
Download Multiple Different Files in Parallel
Code:
aria2c --force-sequential=false "url1 url2 ..."
Motivation: In scenarios where you need several files from different locations, downloading them one by one can be inefficient. This command allows you to fetch multiple files concurrently, drastically reducing total waiting time by parallelizing the download process.
Explanation:
aria2c
: Invokes the aria2c command line utility.--force-sequential=false
: Ensures that downloads are performed in parallel rather than sequentially."url1 url2 ..."
: A series of URLs from which the files will be downloaded.
Example Output:
[#1 SIZE:5.8MiB/5.8MiB(100%) #2 SIZE:9.4MiB/9.4MiB(100%)]
Download completed
Download the Same File from Different Mirrors and Verify the Checksum of the Downloaded File
Code:
aria2c --checksum=sha-256=hash "url1" "url2" "urlN"
Motivation: Using multiple mirror sites to download a single file can increase reliability, especially if one of the mirrors is slow or temporarily inaccessible. Verifying the checksum ensures data integrity by allowing you to confirm that the downloaded file is identical to the original.
Explanation:
aria2c
: Invokes the aria2c command line utility.--checksum=sha-256=hash
: Specifies the SHA-256 checksum value to be verified against the download."url1" "url2" "urlN"
: Multiple URLs (mirrors) where the same file can be downloaded.
Example Output:
[#1 SIZE:7.2MiB/7.2MiB(100%) CN:4 DL:830KiB ETA:0s]
Checksum validation SUCCESS.
Download completed
Download the URIs Listed in a File with a Specific Number of Parallel Downloads
Code:
aria2c --input-file=path/to/file --max-concurrent-downloads=number_of_downloads
Motivation: When dealing with a lengthy list of URLs for download, it’s convenient to store them in a file rather than executing individual commands for each. This command also lets you optimize network usage by setting the number of concurrent downloads, balancing speed and bandwidth consumption.
Explanation:
aria2c
: Invokes the aria2c command line utility.--input-file=path/to/file
: Points to the text file containing the list of URLs.--max-concurrent-downloads=number_of_downloads
: Sets the limit for concurrent downloads.
Example Output:
[#1-4 SIZE:1.2MiB/1.2MiB(100%) CN:4 DL:842KiB ETA:0s]
All downloads successfully completed.
Download with Multiple Connections
Code:
aria2c --split=number_of_connections "url"
Motivation: Splitting downloads into multiple connections can significantly enhance download speed, especially on high-bandwidth networks. Rather than downloading a file linearly, the file is divided into segments, each downloaded simultaneously, thereby minimizing the overall download time.
Explanation:
aria2c
: Invokes the aria2c command line utility.--split=number_of_connections
: Determines how many segments (or connections) to split the download into."url"
: Specifies the single file URL.
Example Output:
[#1 SIZE:4.3MiB/4.3MiB(100%) CN:5 DL:1.26MiB ETA:0s]
Download completed.
FTP Download with Username and Password
Code:
aria2c --ftp-user=username --ftp-passwd=password "url"
Motivation: Accessing FTP servers often requires authentication. This command helps automate the download process from an FTP server by providing your login credentials directly in the command line, easing the process for frequent FTP file transfers.
Explanation:
aria2c
: Invokes the aria2c command line utility.--ftp-user=username
: Defines the username required for FTP server access.--ftp-passwd=password
: Specifies the corresponding password for FTP access."url"
: FTP link of the file you wish to download.
Example Output:
[#1 SIZE:2.7MiB/2.7MiB(100%) CN:1 DL:1.02MiB ETA:0s]
Download completed.
Limit Download Speed in Bytes/s
Code:
aria2c --max-download-limit=speed "url"
Motivation: For environments where bandwidth is limited or shared, controlling the download speed can prevent aria2c from monopolizing network resources. Set a maximum download speed to ensure other network activities can proceed smoothly.
Explanation:
aria2c
: Invokes the aria2c command line utility.--max-download-limit=speed
: Defines a cap for the download speed in bytes per second."url"
: The URL from which the file will be downloaded.
Example Output:
[#1 SIZE:900KiB/3.0MiB(30%) CN:1 DL:300KiB/s ETA:7s MAX:300KiB/s]
Download completed.
Conclusion
Aria2c stands as a versatile, powerful command-line tool for downloading files across numerous platforms and protocols. With its comprehensive features, users can customize download processes to suit specific needs, whether dealing with simple single-file downloads or handling complex downloading tasks that involve multiple connections, mirrors, or protocol-specific requirements. Aria2c ensures efficient, reliable, and secure downloads, making it an indispensable tool for tech-savvy individuals and organizations alike.