Linux wget Command — Downloading Files and Automating File Retrieval¶
wget(World Wide Web Get) is a command-line utility used to download files from web servers using protocols such as HTTP, HTTPS, and FTP. It is designed for reliable, non-interactive downloads and supports features such as resume downloads, recursive downloads, website mirroring, background downloads, authentication, bandwidth limiting, and automation.wgetis widely used by Linux administrators, DevOps engineers, Cloud Architects, Platform Engineers, Site Reliability Engineers (SRE), and System Engineers for downloading software, backups, configuration files, datasets, and application artifacts.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand the
wgetcommand - Download files from the Internet
- Resume interrupted downloads
- Mirror websites
- Perform recursive downloads
- Download files in the background
- Automate software downloads
Prerequisites¶
Complete:
- Linux
ipCommand - Linux
ssCommand - Linux
netstatCommand - Linux
tcpdumpCommand - Linux
tracerouteCommand - Linux
digCommand - Linux
nslookupCommand - Linux
curlCommand
Basic understanding of:
- HTTP
- HTTPS
- URLs
- Linux File System
Why Learn wget?¶
Imagine you need to:
- Download an ISO image
- Download Kubernetes binaries
- Download Terraform
- Retrieve backup files
- Download logs
- Mirror documentation
Instead of opening a browser, Linux engineers use:
because it supports:
- Automation
- Resume Downloads
- Background Downloads
- Recursive Downloads
What is wget?¶
wget stands for:
It retrieves files from remote servers.
Supported protocols include:
- HTTP
- HTTPS
- FTP
Unlike curl, wget is primarily designed for downloading files.
Basic Syntax¶
Example:
The file is downloaded into the current directory.
Download a File¶
Output:
Save with a Different Filename¶
Resume Interrupted Download¶
This continues downloading from where it stopped.
Useful for:
- Large ISO Files
- VM Images
- Backups
Download in Background¶
The download continues even after you close the terminal session (subject to system conditions).
Log file:
Limit Download Speed¶
Useful to reduce bandwidth consumption.
Retry Failed Downloads¶
Retries ten times before giving up.
Set Download Timeout¶
Stops waiting after twenty seconds.
Download Multiple Files¶
Create:
Contents:
Download:
Recursive Download¶
Downloads linked files recursively.
Mirror a Website¶
Mirror mode enables options suitable for creating a local copy of a website.
Useful for:
- Documentation
- Static Websites
- Offline Viewing
Download Only Specific File Types¶
Example:
Downloads only PDF files.
Reject File Types¶
Example:
Skips image files.
Continue Recursive Download¶
Download Using Authentication¶
Basic authentication.
Ignore TLS Certificate Validation¶
Warning: Use this option only in trusted testing environments. Avoid disabling certificate validation in production.
Download via FTP¶
Enterprise Example¶
Download application package.
Verify checksum.
Extract.
Deploy.
Cloud Perspective¶
Cloud engineers use wget to download:
- CLI Tools
- Terraform
- Kubernetes Binaries
- Backup Files
- Deployment Packages
- Cloud Agent Software
Kubernetes Perspective¶
Common downloads include:
Other examples:
- Helm
- Container Network Interface (CNI) Plugins
- YAML Files
- Operators
- Container Runtime Packages
Linux Perspective¶
Download file.
Resume download.
Mirror website.
Download in background.
Common wget Options¶
| Option | Purpose |
|---|---|
-O | Save with custom filename |
-c | Resume download |
-b | Background download |
-i | Read URLs from file |
-r | Recursive download |
-m | Mirror website |
--limit-rate | Limit bandwidth |
--tries | Retry failed downloads |
--timeout | Set timeout |
--user | Username |
--password | Password |
Hands-on Lab¶
Task 1¶
Download a file.
Task 2¶
Save using another filename.
Task 3¶
Resume a download.
Task 4¶
Download in background.
Task 5¶
Download multiple files.
Task 6¶
Mirror a website.
Task 7¶
Download only PDF documents from a documentation site.
Task 8¶
Compare downloading a large file using:
wgetcurl
Identify which tool is more appropriate for different use cases.
Production Troubleshooting¶
Problem:
Solution:
This:
- Resumes interrupted downloads
- Retries failures
- Uses a longer timeout
Ideal for unstable network connections.
wget vs curl¶
| wget | curl |
|---|---|
| Optimized for Downloads | Optimized for Data Transfer |
| Resume Downloads | API Testing |
| Website Mirroring | REST API Requests |
| Recursive Downloads | Custom HTTP Methods |
| Background Downloads | Debugging HTTP Traffic |
Common Mistakes¶
❌ Restarting large downloads after interruption.
✅ Use -c to resume.
❌ Ignoring checksum verification.
✅ Verify downloaded files before deployment.
❌ Disabling certificate validation unnecessarily.
✅ Keep Transport Layer Security (TLS) verification enabled in production.
❌ Using wget for complex API testing.
✅ Use curl for API interactions.
❌ Running recursive downloads without limits.
✅ Restrict recursion depth and file types.
Best Practices¶
- Resume interrupted downloads using
-c. - Verify checksums for downloaded software.
- Use HTTPS whenever available.
- Mirror only websites you are authorised to copy.
- Limit recursive downloads to avoid unnecessary traffic.
- Store downloads in organised directories.
- Automate recurring downloads with scripts and schedulers.
Interview Questions¶
Beginner¶
- What is
wget? - How do you resume a download?
- How do you save a file with a different name?
- What does
wget -bdo?
Intermediate¶
- Compare
wgetandcurl. - How do you mirror a website?
- How do you limit download speed?
- How do you download multiple files automatically?
Architect Level¶
- Design an automated software distribution workflow using
wget. - Explain how you would securely download deployment artifacts in production.
- How would you optimize large-scale file distribution across multiple Linux servers?
Summary¶
In this lesson, you learned:
- The
wgetcommand - File Downloads
- Resume Downloads
- Recursive Downloads
- Website Mirroring
- Background Downloads
- Authentication
- Enterprise File Distribution
wget is one of the most reliable file downloading tools available on Linux. It excels at downloading large files, resuming interrupted transfers, mirroring websites, and automating software retrieval. Mastering wget is essential for Linux system administration, DevOps automation, cloud deployments, and infrastructure management.
Key Takeaways¶
wgetis optimized for reliable file downloads.- Use
-cto resume interrupted downloads. - Use
-Oto save files with a custom filename. - Use
-rfor recursive downloads and-mfor website mirroring. wgetis widely used for software distribution, automation, and infrastructure provisioning.- Use
curlfor APIs andwgetfor downloading files and websites.
What's Next?¶
In the next lesson, you'll learn about Network Namespaces.
You'll explore:
- What Network Namespaces are
- Linux Network Isolation
- Virtual Network Interfaces
- veth Pairs
- Bridges
- Container Networking
- Kubernetes Networking Fundamentals
By the end of the lesson, you'll understand how Linux isolates networking between processes, how containers communicate, and how technologies like Docker and Kubernetes build virtual networks using network namespaces.