How to Set Custom User-Agent String in aria2c on Ubuntu
This guide explains how to configure a custom user-agent string when using aria2c on Ubuntu. Changing the user-agent allows you to mimic specific browsers or devices, which can help bypass server-side restrictions or improve compatibility with certain download links. We will cover both temporary command-line flags and permanent configuration file settings to ensure you can manage your download identity effectively.
Using the Command Line
The quickest way to set a custom user-agent is by using the
--user-agent flag directly in your terminal command. This
method applies only to the specific download session you are
running.
Open your terminal and run the following command structure:
aria2c --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" https://example.com/file.zipReplace the string inside the quotes with the specific user-agent you wish to emulate. This tells the server that the request is coming from a different client than the default aria2c identifier.
Using the Configuration File
For a permanent solution that applies to all aria2c downloads, you can modify the configuration file. This is ideal if you frequently encounter servers that block default download managers.
- Open or create the aria2 configuration file located at
~/.aria2/aria2.conf. - Add or edit the following line:
user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
- Save the file and exit the editor.
Any subsequent aria2c commands will now automatically use this custom user-agent string without requiring additional flags. If the configuration file does not exist, you can create it using a text editor like nano or vim.
Verifying the User-Agent
To confirm that your custom user-agent is being sent, you can use a testing service that echoes request headers. Run aria2c against a URL that displays request information, or check the server logs if you have access to them. This ensures that your configuration changes have taken effect before attempting critical downloads.