wget downloads files over HTTP, HTTPS and FTP. Where curl excels at talking to APIs, wget shines at downloading: it resumes broken transfers, retries automatically, works in the background and can mirror entire websites.

Download a file

wget https://example.com/archive.tar.gz
wget -O latest.tar.gz https://example.com/download?id=123     # choose the file name
wget -P /tmp/downloads https://example.com/file.zip           # choose the directory
wget -q https://example.com/file.zip                          # quiet
wget -nv https://example.com/file.zip                         # less verbose, one line per file

Resume an interrupted download

wget -c https://example.com/big.iso

-c (continue) picks up where the partial file stopped — invaluable for multi-gigabyte files on unstable connections.

Retries and timeouts

wget --tries=10 --waitretry=5 --timeout=30 https://example.com/big.iso
wget --tries=0 https://example.com/big.iso     # retry forever

Run in the background

wget -b https://example.com/big.iso
tail -f wget-log

The download continues after you log out. (Running inside tmux or screen is an alternative.)

Limit the speed

wget --limit-rate=5m https://example.com/big.iso     # 5 MB/s

Useful on a production server so a download doesn’t saturate the uplink.

Download many files

Put URLs in a text file, one per line:

wget -i urls.txt
wget -i urls.txt -P downloads/ -nc       # -nc: skip files that already exist

Authentication and headers

wget --user=alice --ask-password https://example.com/private/file.zip
wget --header="Authorization: Bearer $TOKEN" https://api.example.com/export.csv
wget --user-agent="Mozilla/5.0" https://example.com/page

HTTPS options

wget --ca-certificate=ca.pem https://internal.example.com/file
wget --no-check-certificate https://self-signed.local/file     # testing only

Check whether a URL exists

wget --spider https://example.com/sitemap.xml && echo "exists"
wget --spider -S https://example.com 2>&1 | grep "HTTP/"

--spider checks without downloading; -S prints server response headers.

Mirror a website

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent \
  https://example.com/docs/
  • --mirror — recursive with infinite depth and timestamp checking.
  • --convert-links — rewrite links so the copy works offline.
  • --adjust-extension — save pages with .html extensions.
  • --page-requisites — also fetch CSS, JS and images.
  • --no-parent — don’t climb above /docs/.

Be polite on sites you don’t own: add --wait=1 --random-wait --limit-rate=500k, and respect the site’s terms and robots.txt (wget honours it by default during recursion).

Download only certain file types:

wget -r -l 2 -nd -A pdf,zip --no-parent https://example.com/files/

-nd puts everything in one directory instead of recreating the site structure.

Useful for server setup

# Download and verify
wget https://example.com/app.tar.gz https://example.com/app.tar.gz.sha256
sha256sum -c app.tar.gz.sha256

# Download and extract in one step
wget -qO- https://example.com/app.tar.gz | tar xz -C /opt/

# Download a script — read it before running it
wget -qO install.sh https://example.com/install.sh && less install.sh

Avoid wget … | bash with scripts you haven’t read.

wget vs curl

wget curl
Default action Save to file Print to stdout
Recursive download / mirroring Yes No
Resume -c -C -
APIs, custom methods, JSON Basic Excellent
Protocols HTTP(S), FTP Dozens
Library for programs No libcurl

Use wget to fetch files; use curl to talk to services.

Quick reference

Task Command
Download wget URL
Custom name wget -O name URL
Resume wget -c URL
Background wget -b URL
Speed limit wget --limit-rate=2m URL
From a list wget -i urls.txt
Check only wget --spider URL
Mirror wget --mirror -k -E -p -np URL
  • wget
  • Command Line
  • Linux