首页 > Sysadmin > 正文

Install wget on Linux: Check Before You Install

2026-10-26 Sysadmin

Many distros already ship wget. Before installing anything, check the version: one command, and if it is missing, install it from the official source of your distro — usually about two minutes.

Step 1: check the version first

wget --version
# GNU Wget 1.21.4 built on linux-gnu.

If this prints a version, you already have it — go straight to the usage section. Only continue if you get command not found. On WSL Ubuntu 24.04, wget 1.21.4 was present out of the box.

wget is a GNU project [1]; its official page is www.gnu.org/software/wget/ and the manual lives on the official docs site [2] — do not trust the third-party sites with similar names that show up at the top of search results.

Package managers: one line per distro

Distro family Command Notes
Ubuntu / Debian sudo apt install wget Usually already present
RHEL / Rocky / Alma sudo dnf install wget Not in the base install, must be added
# RHEL/Rocky/AlmaLinux (dnf)
sudo dnf install wget
# Fedora (dnf)
sudo dnf install wget
# Rocky/Rocky Linux (dnf, 9.x)
sudo dnf install wget
# Arch (pacman)
sudo pacman -S wget

The Arch example above is a documented form, not something I executed here — this test ran on Ubuntu WSL.

Source build: only when you have to

wget has no other library dependencies, so a source build is just three commands:

./configure
make
sudo make install

A source build is worth it in only two cases: your distro has no package manager at all, or you need a feature that is not in its packaged version. In any other situation, install from the package manager — an upgrade or an uninstall is easier to track.

Three flags worth knowing

-c — resume a broken download:

wget -c https://mirror.example.com/dataset.tar.gz
# Re-running the same command continues from where it stopped

-O — name the output file (capital O, not lowercase o):

wget -O config.yaml https://example.com/config.yaml

-q — quiet mode for scripts:

wget -q https://example.com/health.json
# No output when successful; a non-zero exit code on failure

What broke

  • wget and curl are not interchangeable. wget -O writes the file directly; curl -o behaves differently when combined with redirects. Don’t paste a curl command into a wget script.
  • wget writes the output file even when the server returns 404 — an HTML error page saved as report.pdf. In a script, check the exit code first.
  • Lowercase -o is not an option. If you type it, wget treats the next token as the URL and the download fails for the wrong reason.

Summary

wget, tar, gzip and bash ship in the base image of most images and containers, so check before installing. If wget is missing, add one line: apt on Ubuntu, dnf on RHEL-family distros, pacman on Arch — that is enough for almost every scenario; a source build is only for cases where no package manager exists or you need a feature absent from the packaged build.

Main commands were verified on WSL Ubuntu (24.04); some entries (tools not installed, install commands) were checked against official docs only, not executed.

References

  1. GNU Wget official page — https://www.gnu.org/software/wget/
  2. GNU Wget manual — https://docs.gnu.org/gnu/wget (official docs site)

Related on this site: Ubuntu install Docker: three steps after install, Debian 13 apt mirror switch: pick the source first, WSL2 + Docker Compose full workflow.