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.

SysOps·38 commands·Last updated 2026-07-21
wgetDownloadlinux

Basic Download 7

wget URL
Download a file to the current directory
wget -O filename URL
Download and save as a given name
wget -P /path/to/dir URL
Download to a given directory
wget -b URL
Download in the background
wget -q URL
Quiet download (no progress)
wget -v URL
Verbose output
wget -nc URL
Skip existing files (no-clobber)

Resume 3

wget -c URL
Resume a partial download
wget -c -O filename URL
Resume and save as a given name
wget --continue URL
Resume (same as -c)

Recursive 8

wget -r URL
Recursive download (default depth 5)
wget -r -l 2 URL
Recursive, depth 2
wget -r -np URL
Recursive, no parent directories
wget -r -nd URL
Recursive, no directory structure
wget -r -N URL
Recursive, newer files only
wget -m URL
Mirror a site (equiv. -r -N -l inf --no-remove-listing)
wget --mirror URL
Mirror a site (same as -m)
wget -r -H -D example.com URL
Cross-host but limit to a domain (-H host, -D domain)

Filter 6

wget -A "*.pdf,*.doc" URL
Download only given types
wget -R "*.tmp,*.log" URL
Reject given types
wget --accept-regex ".*\.pdf$" URL
Accept by regex
wget --reject-regex ".*\.tmp$" URL
Reject by regex
wget -I /dir1,/dir2 URL
Download only given directories
wget -X /dir1,/dir2 URL
Exclude given directories

Auth & Proxy 6

wget --user=username --password=pass URL
HTTP authentication
wget --ftp-user=user --ftp-password=pass URL
FTP authentication
wget -e use_proxy=yes -e http_proxy=URL
Use an HTTP proxy
wget -e use_proxy=yes -e https_proxy=URL
Use an HTTPS proxy
wget --no-check-certificate URL
Skip SSL certificate verification
wget --user-agent="Mozilla/5.0" URL
Custom User-Agent (bypass UA checks)

Common Patterns 8

wget -i urls.txt
Download from a list of URLs
wget -r -l 1 -A "*.jpg,*.png" URL
Download all images on a page
wget -r -l 1 --convert-links URL
Download and rewrite links to local
wget -r -l 1 -k -E -p URL
Download a full page (images, CSS, JS)
wget --limit-rate=100k URL
Limit download speed
wget --timeout=30 --tries=3 URL
Set timeout and retry count
wget --spider URL
Check only, don't download (link test)
wget -w 2 --random-wait -r URL
Polite crawl: 2s wait plus random jitter

Command 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