wget Cheatsheet - Download, Resume & Mirror Commands
In scripts, what determines whether a download works is not the transfer itself but what happens after it fails, and wget handles that far better than a browser does. The centrepiece is -c: re-running the same command after an interruption sends a Range header and resumes from the last received byte, which is the difference between success and failure on multi-gigabyte artifacts and mirror syncs. Pair it with --tries and --wait to bound retries, --timeout to avoid hanging on a dead connection, and --retry-on-http-error so recoverable 503s and 429s re-enter the retry loop. The recursive group covers -r depth, -np to stay off parent directories, -A and -R filtering, and -e robots=off. The curl boundary is worth drawing: curl wins for a one-shot fetch whose output should flow into a pipeline, while wget is right when you need resume, recursion, mirroring, or a finished file on disk. Whichever you pick, in unattended jobs the first thing to run out is local disk space, not bandwidth.
Basic Download 7
wget URLwget -O filename URLwget -P /path/to/dir URLwget -b URLwget -q URLwget -v URLwget -nc URLResume 3
wget -c URLwget -c -O filename URLwget --continue URLRecursive 8
wget -r URLwget -r -l 2 URLwget -r -np URLwget -r -nd URLwget -r -N URLwget -m URLwget --mirror URLwget -r -H -D example.com URLFilter 6
wget -A "*.pdf,*.doc" URLwget -R "*.tmp,*.log" URLwget --accept-regex ".*\.pdf$" URLwget --reject-regex ".*\.tmp$" URLwget -I /dir1,/dir2 URLwget -X /dir1,/dir2 URLAuth & Proxy 6
wget --user=username --password=pass URLwget --ftp-user=user --ftp-password=pass URLwget -e use_proxy=yes -e http_proxy=URLwget -e use_proxy=yes -e https_proxy=URLwget --no-check-certificate URLwget --user-agent="Mozilla/5.0" URLCommon Patterns 8
wget -i urls.txtwget -r -l 1 -A "*.jpg,*.png" URLwget -r -l 1 --convert-links URLwget -r -l 1 -k -E -p URLwget --limit-rate=100k URLwget --timeout=30 --tries=3 URLwget --spider URLwget -w 2 --random-wait -r URLCommand Examples
Resume a large download
wget -c https://example.com/large.iso-c 让 wget 带着 Range 头请求续传,配合 --timeout=30 --tries=3 更稳。文件名必须是原来那个,否则 -c 找不到已有文件会从头开始。
Output
Resuming last request: Length: 1048576000 [1048576000/1048576000] HTTP request sent, awaiting response... 206 Partial Content Length: 1048576000 [1039460352/1048576000] 30.0MB/s eta 00:00:03 1048576000 100%[====] 103.95MB 29.87MB/s
Mirror a page including images and CSS
wget -r -l 1 -k -E -p https://example.com/docs/-k 把页面里的链接改成本地路径,-E 保存为 .html,-p 下载图片等附属资源,-l 1 限制只抓一层防止无限递归。
Output
--2026-09-30 15:20:11-- https://example.com/docs/ Resolving example.com (example.com)... 93.184.216.34 Connecting to example.com|93.184.216.34|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 12480 [text/html] Saving to: ‘example.com/docs/index.html’ 2026-09-30 15:20:12 (18.0 MB/s) - 12480 [text/html] saved
Download by file type with a rate limit
wget -r -l 2 -A "*.pdf,*.zip" --limit-rate=500k -P ~/downloads https://example.com/files/-A 白名单只收指定类型,--limit-rate 单位是 KB/s,500k 即约 500KB/s。别忘了 -np,避免顺着上级链接爬出站点范围。
Common Pitfalls
- wget -r without a depth limit or -np can walk off the site and try to download a large part of the internet.
- --no-check-certificate disables verification, allowing man-in-the-middle replacement of downloaded content; debug-only.
- -c resume requires the same filename as the original attempt — renaming restarts the download, and it silently does nothing if the server ignores Range.
- Probe recursive downloads with -l 1 first and confirm the directory structure before widening the scope.
- Check robots.txt and the site terms before recursive downloading; bulk crawling may violate them.
Tips
- wget supports HTTP, HTTPS and FTP, with resume and recursive download.
- Mind the depth (-l) on recursive downloads to avoid pulling too many files.
- Use -m to mirror a site; it auto-handles link conversion and timestamps.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us