Commands.page Logo

How to Use aria2c with Cookies on Ubuntu

This guide details the process of employing the aria2c command-line tool on Ubuntu to download files from servers that require cookie authentication. You will learn how to identify the necessary cookie values from your web browser and inject them into the aria2c command to authorize the download request without needing a logged-in browser session.

Install aria2 on Ubuntu

Before beginning, ensure the aria2 utility is installed on your system. Open your terminal and update your package list, then install the software using the Apt package manager with the following commands:

sudo apt update
sudo apt install aria2

You need to retrieve the specific cookie string that grants access to the file. Open your web browser and navigate to the page containing the download link. Press F12 to open the Developer Tools and select the Network tab. Refresh the page or click the download link to generate a network request. Click on the request name in the list, look for the Request Headers section, and copy the value associated with the Cookie field.

Execute the Download Command

Use the --header flag to pass the copied cookie data directly to aria2c. Construct your command by replacing YOUR_COOKIE_STRING with the data you copied and DOWNLOAD_URL with the direct link to the file:

aria2c --header="Cookie: YOUR_COOKIE_STRING" DOWNLOAD_URL

For example, if your cookie is session=abc123 and the URL is https://example.com/file.zip, the command would look like this:

aria2c --header="Cookie: session=abc123" https://example.com/file.zip

Execute the command in your terminal to start the download. Aria2c will send the request with the provided cookie, allowing the server to authenticate the session and transfer the file to your Ubuntu machine.