How to Configure Global Wget Defaults via .wgetrc
This article provides a quick overview of how to set permanent,
global default options for the wget command-line utility
using the .wgetrc configuration file. By modifying this
file, you can automate your preferred download settings—such as retry
attempts, download directories, proxy configurations, and speed
limits—eliminating the need to type out repetitive command-line switches
every time you use the tool.
Locating or Creating the .wgetrc File
Depending on whether you want to apply settings to a single user or across the entire system, the configuration file resides in one of two places:
- User-Specific Configuration: The primary file is
named
.wgetrcand is located in a user’s home directory (~/.wgetrc). If it does not exist, you can create it using a standard text editor. - System-Wide Configuration: To apply defaults for
all users on a machine, the settings are managed in the global
initialization file, typically located at
/etc/wgetrc.
Common Configuration Syntax and Examples
The syntax within a .wgetrc file is straightforward. It
consists of command = value pairs, with one directive per
line. Lines starting with a # symbol are treated as
comments and are ignored by the system.
Here are some of the most useful options you can add to your configuration file:
# Set the maximum number of retry attempts on failure
tries = 20
# Set the default background download mode to off
background = off
# Automatically resume partially downloaded files
continue = on
# Limit download speed to prevent bandwidth hogging (e.g., 500 Kilobytes per second)
limit_rate = 500k
# Specify a default directory where all downloads should be saved
dir_prefix = ~/Downloads
# Mask the user-agent to look like a standard web browser
user_agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Verifying and Overriding Defaults
Once you save the file, wget will automatically read and
apply these options every time it is executed. If a specific scenario
requires you to temporarily bypass these global defaults, you can easily
override them by explicitly passing the corresponding flag directly in
your terminal command. For instance, if your .wgetrc limits
your download speed but you need full bandwidth for a single file,
running wget --limit-rate=0 [URL] will prioritize the
command-line instruction over the file configuration.