Quick take: The wget command downloads files from the web non-interactively. Use wget url to fetch a file, -c to resume an interrupted download, -O to set the filename, and -b to download in the background.
Introduction
The wget command is a dedicated, non-interactive downloader. Unlike a browser, it works perfectly in scripts and over SSH, can resume broken downloads, retries automatically on flaky connections, and can even mirror an entire site for offline use.
This guide covers single downloads, resuming and background transfers, bandwidth limits, and recursive mirroring.
Syntax
The basic syntax of the wget command is:
wget [OPTIONS] URLCommon Options and Parameters
The most useful options and parameters for the wget command:
| Option | Description |
|---|---|
| -O FILE | Save the download under a specific filename. |
| -c | Continue (resume) a partially downloaded file. |
| -b | Go to background immediately after starting. |
| -q | Quiet — suppress output. |
| -P DIR | Save files into a target directory. |
| --limit-rate=R | Throttle the download speed (e.g. 500k). |
| -r | Recursive download (follow links). |
| -np | No parent — do not ascend above the starting directory. |
| --mirror | Mirror a site (recursive, timestamping, infinite depth). |
| --user / --password | Supply credentials for protected downloads. |
Practical Examples
Real wget commands you can run today:
# Download a file
wget https://example.com/app.tar.gz
# Save under a different name
wget -O latest.tar.gz https://example.com/download
# Resume an interrupted download
wget -c https://example.com/big.iso
# Download in the background
wget -b https://example.com/big.iso
# Limit the download speed
wget --limit-rate=1m https://example.com/big.iso
# Mirror a documentation site
wget --mirror -np -P ./docs https://docs.example.com/Mirroring and Automated Downloads
wget excels at unattended, scripted downloads where resilience matters. Its retry, resume, and recursion features make it dependable over flaky links and ideal for cron jobs.
# Robust download with retries and resume
wget -c --tries=5 --timeout=30 https://example.com/big.iso
# Mirror a docs site for offline reading
wget --mirror --convert-links --page-requisites -np \
-P ./docs https://docs.example.com/
# Download every file listed in a text file
wget -i urls.txtThe --convert-links and --page-requisites options make a mirrored site browsable offline by rewriting links and pulling in CSS and images, turning wget into a simple site archiver.
Tips and Best Practices
- Use
-cto recover from a dropped connection instead of starting a large download over. - For background downloads, track progress with
tail -f wget-logafter using-b. - Combine
--mirrorwith-npand-Pto grab a docs site into a folder without climbing above the start URL.
Final Thoughts
wget is the dependable choice for downloading files in scripts and over SSH, with resume, retries, and full-site mirroring built in. Remember -c to resume, -O to rename, and --mirror for offline copies. When you need to craft API requests rather than just download, reach for curl instead.
FAQ: wget Command in Linux
How do I download a file with wget?+
Run wget url. The file is saved in the current directory under its original name. Use -O name to choose a different filename, or -P dir to save it elsewhere.
How do I resume an interrupted download?+
Use the -c flag: wget -c url continues a partial download from where it stopped instead of starting over.
How do I download a file in the background?+
Use -b: wget -b url detaches the download and writes progress to wget-log, which you can follow with tail -f wget-log.
How do I mirror a website with wget?+
Use wget --mirror -np -P ./out https://site/. --mirror enables recursive, timestamped downloading and -np stops it climbing above the start path.
What is the difference between wget and curl?+
wget is a downloader with easy resuming and recursive mirroring. curl is a flexible transfer tool aimed at single requests and APIs, with fine control over method, headers, and body.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support