How to Set Output Directory in aria2?
The aria2 command-line download utility allows users to
specify a custom output directory for downloaded files using the
-d (or --dir) option. By default,
aria2 saves files in the current working directory from
which the command is executed. By appending the directory flag followed
by the desired absolute or relative file path, you can efficiently
organize your downloads and bypass default storage locations.
Using the Directory Command-Line Flag
To save a file to a specific location, insert the -d
flag into your terminal command, followed immediately by the path to
your target folder.
aria2c -d /path/to/downloads https://example.com/file.zipIf the specified directory does not exist, aria2 will
automatically create it before initiating the file transfer. You can
also use relative paths, such as ./downloads, to save files
relative to your current location in the terminal.
Specifying Output Directory and File Name Together
While the -d flag controls the destination folder, you
can pair it with the -o (or --out) flag to
rename the file simultaneously. This ensures the download goes to the
correct folder under a specific filename.
aria2c -d /home/user/documents -o report.pdf https://example.com/document_id_9874.pdfAutomating the Download Directory via Configuration
If you consistently download files to the same location, you can set
a permanent default output directory in the aria2
configuration file (aria2.conf). This removes the need to
manually type the path every time.
- Open or create your
aria2.conffile (typically located at~/.config/aria2/aria2.confon Linux/macOS). - Add the following line to the file:
dir=/path/to/default/downloads
Once saved, any standard aria2c command will
automatically route files to that specified folder unless you explicitly
override it in the command line using the -d flag.