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] URL

Common Options and Parameters

The most useful options and parameters for the wget command:

OptionDescription
-O FILESave the download under a specific filename.
-cContinue (resume) a partially downloaded file.
-bGo to background immediately after starting.
-qQuiet — suppress output.
-P DIRSave files into a target directory.
--limit-rate=RThrottle the download speed (e.g. 500k).
-rRecursive download (follow links).
-npNo parent — do not ascend above the starting directory.
--mirrorMirror a site (recursive, timestamping, infinite depth).
--user / --passwordSupply 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.txt

The --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 -c to recover from a dropped connection instead of starting a large download over.
  • For background downloads, track progress with tail -f wget-log after using -b.
  • Combine --mirror with -np and -P to 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