Commands.page Logo

How to Use aria2c to Download and Verify Hash on Ubuntu

This article provides a concise guide on using the aria2c command-line tool within the Ubuntu operating system to download files and validate their checksums in a single operation. It covers the necessary installation steps, the correct command syntax for specifying hash algorithms, and how to interpret the verification results provided by the utility to ensure file integrity.

Install aria2 on Ubuntu

Start by installing the aria2 package using the APT package manager. Open your terminal and execute the following commands to update your repository list and install the tool:

sudo apt update
sudo apt install aria2

Using the Checksum Option

The core functionality relies on the --checksum flag. This option allows you to pass the expected hash value directly into the download command. The format requires you to specify the hash type followed by an equals sign and the hash string itself.

The structure is --checksum=type=hash. Supported types include md5, sha-1, sha-256, and sha-512.

Execution Example

To download a file and verify it using a SHA-256 hash, run the following command in your terminal:

aria2c --checksum=sha-256=YOUR_HASH_HERE https://example.com/file.zip

Replace YOUR_HASH_HERE with the actual checksum provided by the software vendor and the URL with the direct link to the file.

Verification Results

Upon completion of the download, aria2c automatically computes the hash of the saved file and compares it to the one you supplied. If the values match, the process exits successfully, and the file remains on your disk. If the values do not match, aria2c reports a checksum error and removes the corrupted file to ensure safety. This workflow eliminates the need for manual verification steps after the download finishes.