What is Wget Command Line Tool
This article provides a comprehensive overview of Wget, a popular command-line utility used for retrieving files from the web. You will learn what Wget is, its primary features, how it operates under the hood, and practical examples of how to use it for downloading files and mirroring websites.
Understanding Wget
Wget (which stands for “World Wide Web get”) is a free, open-source command-line utility used to download files from the internet. Developed as part of the GNU Project, it supports downloading via widely used internet protocols including HTTP, HTTPS, and FTP.
Unlike web browsers, Wget is designed to be non-interactive. This means it can run in the background, allowing users to initiate a download, log off from the system, and let the process complete without any user intervention. This capability makes it an invaluable tool for system administrators, developers, and power users who need to automate data retrieval tasks.
Key Features of Wget
- Robustness: Wget is designed to handle slow, unstable, or unreliable network connections. If a download is interrupted due to a network failure, Wget will continuously attempt to reconnect and resume the download from where it left off.
- Recursive Downloading: Wget can function like a web crawler. It can follow links in HTML pages to download directories and entire websites sequentially, recreating the original directory structure on your local machine.
- Background Operation: You can start a download and redirect Wget to run in the background. The output can be redirected to a log file so you can monitor the progress later.
- Wildcard Support: Wget supports wildcards, allowing
users to download specific file types (like all
.pdfor.zipfiles) from a directory easily.
Common Wget Commands and Examples
To use Wget, you execute it from your terminal or command prompt followed by the URL of the file you want to download.
1. Downloading a Single File
To download a file and save it in your current directory:
wget https://example.com/file.zip2. Saving a File with a Different Name
You can use the -O option to specify a new filename for
the downloaded resource:
wget -O customized_name.zip https://example.com/file.zip3. Resuming an Interrupted Download
If a large download gets cut off, you can resume it using the
-c option:
wget -c https://example.com/largefile.iso4. Downloading in the Background
To run a download in the background, use the -b
option:
wget -b https://example.com/largefile.iso5. Mirroring an Entire Website
To download a complete website for local offline viewing, you can use the mirror option:
wget -m https://example.comAdditional Resources
Wget offers a vast array of command-line arguments to customize your downloading experience, including rate limiting, user-agent customization, and proxy configuration. For a complete list of commands, syntax options, and advanced configurations, refer to the Wget Command line tool documentation website.