Introduction to Wget
Wget is one of the most versatile and reliable tools any Linux user can have in his arsenal. Designed to operate from the command line, it allows you to download files using HTTP, HTTPS and FTP protocols with a simple but powerful syntax. Its name comes from "World Wide Web get," and since its appearance in the late 1990s it has become a standard for system managers, developers and advanced users who need to automate network resources.
Installation and verification
In most Linux distributions, Wget comes pre-installed, but if missing, its installation is trivial. In Debian / Ubuntu: sudo apt update & & sudo apt install wget. In Red Hat, CentOS or Fedora: sudo dnf install wget (or yum in old versions). After installing, check the version with wget -version, which shows the release number and the compiled features, such as support for SSL or IPv6.
Basic syntax
The fundamental syntax is wget [options] URL. The URL indicates the resource to be obtained (file, FTP directory or website). The options change the behavior: destination directory, number of reattempts, speed limit, authentication, etc. For example, wget -O informe.pdf https: / / example.com / informe.pdf download and save the file with the specified name.
Most commonly used options
The options that are most used on a daily basis are listed below.
- - Ofile: defines the name of the output file.
- -c: continues a interrupted download, reusing the already downloaded.
- -r: activates the recursive mode to download full directories or websites.
- -ldepth: limits the level of recursion (default 5).
- -np: does not ascend to the parent directory when downloading recursively.
- -q: silent mode, delete the information output.
- -limit =speed: limits bandwidth (e.g. 200k).
- -user-agent =chain: pretends to be another browser or tool.
Practical examples
These commands illustrate how to combine options in real situations.
- Download and rename: wget -O kernel .tar.xz https: / / cdn.kernel / pub / linux / kernel / v5.x / linux-5.15.tar.xz
- Documentation mirror for offline use: wget -r -l 2 -k -p https: / / example.com / docs /
- Resume a large ISO: wget -c https: / / republicas.ubuntu.com / 22.04 / ubuntu-22.04-desktop-amd64.iso
- Limit bandwidth to 300 KB / s: wget -limit rate = 300k https: / / velocidad.test / archivo.zip
- FTP with authentication: wget -ftp-user = backups -ftp-password = Secure123 ftp: / / servor.com / backup. tar.gz
Download full websites (mirror mode)
To create a navigable local copy of a site, use the -m option (equivalent to -r -N -l inf -no-remove -listing). Combine it with -k to convert links to local routes and -p to download all the necessary resources (images, CSS, JavaScript). Example: wget -m -k -p https: / / example.com / tutorial / will leave the files ready to open index.html in your browser without connection.
Automation, scripts and good practices
Wget is easily integrated into shell scripts and cron tasks. A simple example of backup with log record:
#!/bin/bash
LOG=/var/log/wget_backup.log
wget -c -o $LOG https://respaldos.example.com/copia.tar.gz
if [ $? -eq 0 ]; then
echo "Descarga completada a $(date)" >> $LOG
else
echo "Error en la descarga" | mail -s "Falló Wget" admin@example.com
fi
As for security, it always verifies Checksums or GPG signatures from downloaded files. Avoid using -no-check-certify unless it is essential, as it disables SSL validation. Limit the bandwidth with -limit-rate if the network is shared and run Wget under a user with reduced privileges.
Conclusion
Wget remains, after more than two decades, one of the most reliable and flexible tools for downloading files into Linux. Its combination of simplicity, power and automation capacity makes it essential for both occasional users and professionals who manage servers or develop complex workflows. Dominating your basic and advanced options will allow you to save time, reduce bandwidth waste and ensure that your downloads are summary and secure. In addition, its presence in virtually all distributions makes it an always available tool, without the need for external dependencies.
Advanced use: proxies, cookies and authentication
Wget also allows you to work behind proxies, manage cookies and authenticate yourself in sites that require login. These capabilities make it useful to download intranets, protected APIs or private repositories.
- -proxy =host: port: defines the proxy server to use.
- -proxy-user =user-proxy-password =key: authentication in the proxy.
- -load-cookiesfile: previously stored cookies.
- -save-cookiesfile: save cookies received during the session.
- -http-user =user-http-password =key: basic authentication on HTTP / HTTPS servers.
- -auth-no-challenge: sends credentials without waiting for the server challenge (useful in some cases).
Debugging and recording of output
To solve problems, Wget offers debugging options that show in detail what happens during the connection. The output log can be redirected to a file for further analysis, making it easier to identify certificate errors, readdresses or waiting times.
- -d: activates the debugging mode, printing handshake and header information.
- -orfile: redirect all output messages to the specified file.
- -debug: equivalent to -d, available in more recent versions.
- -no-verbose: removes the information output but keeps the errors.
Limitations and alternatives
Although Wget is extremely capable, it has some limitations: it does not interpret JavaScript, so it cannot download content generated dynamically by client scripts. For such cases, tools like curl with scripting capabilities or headless browsers (Puppeteer, Playwright) are more suitable. In addition, Wget does not support parallel downloads of multiple connections within the same task; if you need to maximize bandwidth, consider using axel or aria2. However, for most static download and simple automation scenarios, Wget remains the simplest and most reliable option. In short, choosing the right tool depends on the type of content and the level of automation required, but Wget remains an excellent starting point for most Linux download tasks.


