What Is Wget Command and How to Use It
Wget is a powerful, open-source command-line utility used to download files from the internet via protocols like HTTP, HTTPS, and FTP. This article provides a clear overview of what Wget is, how it functions, its key features, and practical examples for automating and managing web downloads directly from your terminal.
Understanding Wget
GNU Wget is a non-interactive network downloader. Being non-interactive means it can operate effectively in the background while a user is logged off, making it an essential tool for scripts, cron jobs, and automated data pipelines. It is designed for robustness over slow or unstable network connections, automatically retrying failed downloads until a file is fully retrieved.
For complete parameter references and manual details, consult the Wget Command line tool documentation website.
Key Features
- Resilient Downloads: Wget can resume interrupted downloads using the REST and RANGE primitives, saving bandwidth and time.
- Recursive Retrieval: It can mirror entire websites or download directory trees by traversing hyperlinks sequentially.
- Broad Protocol Support: Native support for HTTP, HTTPS, and FTP protocols, including retrieval through HTTP proxies.
- Low Resource Footprint: Lightweight execution that requires minimal system resources, ideal for headless servers and embedded systems.
Common Wget Commands
1. Download a Single File
To download a file to the current working directory:
wget https://example.com/file.zip2. Save Under a Different Name
Use the -O option to rename the downloaded file:
wget -O newname.zip https://example.com/file.zip3. Resume an Incomplete Download
Use the -c flag to pick up where a broken transfer left
off:
wget -c https://example.com/largefile.iso4. Download in the Background
To run a download in the background without keeping the terminal
session open, use the -b option:
wget -b https://example.com/archive.tar.gz5. Mirror a Website
The -m option enables mirroring, making it easy to
create local backups of static web pages:
wget -m https://example.com