In this guide, you’ll explore the power of the wget command, learn its key features, understand how to install it on major Linux distributions, and see practical examples for real-world usage.

What Is Wget?

Wget is a widely used command-line utility for downloading files from the internet via protocols like HTTP, HTTPS, FTP, and FTPS.

Key points about wget:

  • Non-interactive: works in scripts or background tasks
  • Supports resumable downloads
  • Can handle multiple files and directories recursively
  • Reliable for automation and file retrieval

While curl is great for sending requests and interacting with web services, wget specializes in file downloads with simplicity and reliability.

Key Features of Wget

  • Download entire directories recursively
  • Support for proxies
  • Automatic following of redirects
  • Resume interrupted downloads
  • Limit download rates
  • Specify output file names
  • Run downloads in the background
  • IPv4 and IPv6 support
  • Timeout management and authentication handling

Wget works seamlessly on Linux, Windows, and macOS, making it a versatile cross-platform tool.

How to Install Wget on Linux

Wget is pre-installed on most distributions. If it’s missing, you can install it using your package manager:

# Debian/Ubuntu/Pop!_OS
sudo apt install wget -y# Red Hat/Fedora/AlmaLinux
sudo yum install wget -y# Arch/Manjaro/EndeavourOS
sudo pacman -Sy wget# OpenSUSE
sudo zypper install wget -y# Gentoo
sudo emerge -a net-misc/wget

Verify installation:

wget --version

Basic Wget Usage

The general syntax:

wget [OPTION] [URL]

1. Download a Single File

wget https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz

2. Download Multiple Files

wget https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz https://ftp.gnu.org/gnu/wget/wget2-latest.tar.lz

Or from a text file:

wget -i urls.txt

3. Download Files via HTTP and FTP

wget https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz ftp://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz.sig

4. Save File with a Different Name

wget -O wget.tar.gz https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz

5. Specify Output Directory

wget -P ~/Downloads/ https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz

6. Use a Custom User Agent

wget --user-agent="Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/115.0" https://ftp.gnu.org/gnu/wget/wget2-latest.tar.gz

7. Resume a Large Download

wget -c https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.0.0-amd64-DVD-1.iso

Without -c, an interrupted download will start over with a .1 extension.

8. Limit Download Rate

wget -c --limit-rate=500k https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.0.0-amd64-DVD-1.iso

9. Download in the Background

wget -c --limit-rate=500k -b https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.0.0-amd64-DVD-1.iso
  • Check background downloads:
ps aux | grep wget
  • Stop a process:
kill <PID>

10. Mirror a Website Recursively

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://example.com

Flags breakdown:

  • --mirror: enable recursive download
  • --convert-links: adjust links for offline browsing
  • --adjust-extension: assign proper file extensions
  • --page-requisites: download all assets (images, CSS, JS)
  • --no-parent: stay within the directory

⚠️ Only mirror websites with permission.

11. Download Password-Protected Files

HTTP:

wget --http-user=USER --http-password=PASSWORD https://example.com/file.zip

FTP:

wget --ftp-user=USER --ftp-password=PASSWORD ftp://example.com/file.zip

12. Use Cookies

wget --load-cookies cookies.txt https://example.com/protected-file.zip

13. Ignore SSL Certificate Check

wget --no-check-certificate https://example.com/file.zip

14. Help and Manual

wget --help
man wget

Conclusion

Wget is an essential command-line tool for downloading files, automating downloads, mirroring websites, and handling HTTP/FTP tasks efficiently. With its versatility and cross-platform support, mastering wget is invaluable for Linux users and system administrators alike.

READ 👉  How to install Windows 11 on an old processor or without a compatible TPM?

Whether you are fetching a single file, resuming a large download, or setting up automated scripts, wget makes it simple and reliable.

Did you enjoy this article? Feel free to share it on social media and subscribe to our newsletter so you never miss a post!

And if you'd like to go a step further in supporting us, you can treat us to a virtual coffee ☕️. Thank you for your support ❤️!
Buy Me a Coffee

Categorized in: