How-to

The wget Command with Examples

wget is built to get files and keep trying until it does. A handful of flags cover nearly everything an admin downloads.

What is the basic use?

wget https://downloads.example.org/release/tool-3.2-linux-amd64.tar.gz

wget saves the file under its remote name in the current folder, shows a progress bar with speed and remaining time, follows redirects and retries on network errors. If a file with that name exists, the new one gets a .1 suffix rather than overwriting it. Install wget with apt install wget or dnf install wget if a minimal image lacks it.

How do I choose the name or folder?

wget -O /opt/tool.tar.gz https://downloads.example.org/release/tool-3.2-linux-amd64.tar.gz
wget -P /srv/isos https://mirror.example.org/images/rocky-9-x86_64-minimal.iso

-O sets the exact output path; -O - writes to standard output for pipes. -P keeps the remote name but saves into a folder. On Arm machines such as A1, pick files labeled arm64 or aarch64.

How do I resume a big download?

wget -c https://mirror.example.org/datasets/osm-planet-latest.osm.pbf

-c continues a partial file instead of starting over, as long as the server supports range requests, which nearly all do. Large data sets, disk images and backups pulled from another machine are where this saves the most time.

How do I control retries and timeouts?

OptionEffect
--tries=50Retry up to 50 times (default 20; 0 means forever)
--waitretry=10Back off up to 10 seconds between retries
--timeout=30Network timeout for DNS, connect and read
--retry-connrefusedAlso retry when the connection is refused
--limit-rate=25mCap speed at about 25 MB per second

The rate limit matters on fast ports. Every model from S1 upward has 10 or 25 Gbps ports, so an uncapped download can crowd out live traffic while it runs.

How do I download a list of files?

wget -i /root/urls.txt -P /srv/incoming --no-verbose
wget -i urls.txt -nc         # skip files that already exist

One URL per line. -nc makes a rerun skip finished files, so a failed batch can be restarted without fetching everything again. For checksums, keep a SHA256SUMS file alongside and run sha256sum -c SHA256SUMS afterwards.

How do I run it in the background?

wget -b -o /var/log/wget-dataset.log -c https://mirror.example.org/datasets/archive-2026.tar.zst
tail -f /var/log/wget-dataset.log

-b detaches immediately, so the download continues after you log out. A tmux or screen session works too, and lets you come back to the live progress bar.

How do I mirror a site or folder?

wget -m -np -k -E -p --wait=1 https://docs.example.net/manual/
  • -m: mirror mode, recursive with timestamps.
  • -np: never climb above the starting folder.
  • -k: rewrite links so the copy works offline.
  • -E and -p: save pages with .html extensions and fetch the images and styles they need.
  • --wait=1: pause between requests, a courtesy to the server.

Mirroring someone else's site should respect their terms and robots rules; mirroring your own is a quick way to archive a static version before a redesign.

How do I make wget quiet for scripts?

-q prints nothing; -nv prints one line per file; -q --show-progress shows only the bar. In scripts, check the exit status: 0 is success, 4 a network failure, 8 an HTTP error such as 404. A typical cron line: wget -q -O /srv/feeds/rates.json https://data.example.org/rates.json || logger -t rates "download failed".

How does it compare with curl?

wget is the stronger downloader; curl is the stronger request tool. The comparison is in wget vs curl. For copying between your own machines, rsync or scp over SSH is usually simpler and encrypted end to end; see The scp command.

How do I authenticate with wget?

For basic authentication, --user=ops --ask-password prompts instead of putting the password on the command line. For tokens, add a header: --header="Authorization: Bearer $TOKEN". Both keep secrets out of shell history when used with variables or prompts.

Keep Reading

wget vs curl

Two download tools with different strengths: wget for recursive and resumable fetching, curl for talking to APIs in any protocol.

Open

The curl command

A practical tour of curl for server admins: fetching, saving, timing, debugging, retrying, resolving and the flags that make scripts reliable.

Open

Extract .tar.gz files

Unpack tar.gz and .tgz archives from the command line: target folders, single files, stripped paths, ownership and safe handling of unknown archives.

Open

Port speed

What 1, 10 and 25 Gbps network ports mean in real transfer times, and which of our 68 machines carry each speed.

Open

FAQ

Quick Answers

Run the same command with -c; wget continues the partial file.

Use -O followed by the path, or -P to keep the name and choose a folder.

Add -b and a log file with -o; the download keeps running after you log out.

Use --limit-rate, for example --limit-rate=25m for about 25 MB per second.

Use wget -m -np -k -E -p with a polite --wait between requests.