sodcalculator

10 Tech How-To

Fix wget command not found error in Linux

Guide 10-46170 · Updated · Step by step

If you see “wget: command not found” in Linux, the fix is to install the missing package with your distribution’s package manager. This error means the wget utility is not installed by default on your system, which is common on minimal or container-based installations.

What Is wget and Why Is It Missing?

wget is a command-line tool for downloading files from the internet. It supports HTTP, HTTPS, and FTP protocols, and is widely used in scripts and automated tasks because it can follow links, resume interrupted downloads, and mirror websites. Many Linux distributions include wget by default, but minimal installs (like Docker containers, Alpine Linux, or a custom server build) often omit it to save space. If you are using a stripped-down environment or a recent release that switched to a different default downloader, you will see the error.

How to Install wget on Different Distributions

The installation command depends on your package manager. Run the appropriate one for your system:

  • Debian/Ubuntu: sudo apt update && sudo apt install wget
  • RHEL/CentOS/Fedora: sudo dnf install wget (or sudo yum install wget on older versions)
  • Arch Linux: sudo pacman -S wget
  • Alpine Linux: apk add wget
  • openSUSE: sudo zypper install wget

After installation, verify it works with wget --version. If you are in a container and do not have root, you may need to rebuild the image with wget included or use a different download tool.

Why Does the Error Happen Even When wget Is Installed?

Sometimes wget is installed but still not found. This usually means the executable is not in your PATH. For example, on some systems wget is located in /usr/bin/wget or /usr/local/bin/wget, and if your PATH does not include that directory, the shell cannot locate it. Check with which wget or type -a wget. If it shows a path, run it directly with the full path. If it does not show anything, the package is not installed.

What to Do If You Cannot Install wget

If you are on a system where you cannot install packages (no root, no network, or restricted environment), you have alternatives:

  • curl: Often installed by default. Use curl -O URL to download a file, or curl -o filename URL to specify the output name.
  • busybox wget: Some minimal systems include busybox, which has a wget applet. Try busybox wget.
  • Python: If Python is available, use python3 -c "import urllib.request; urllib.request.urlretrieve('URL', 'filename')" to download a file.
  • Git: You can clone a repository with git clone if the file is in a Git repo.

These workarounds are handy in containers or when you are troubleshooting a broken system.

Common Problems and Their Solutions

After installing wget, you might still face issues. Here are typical ones:

  • SSL certificate errors: If you get “Unable to locally verify the issuer’s authority,” your system may lack CA certificates. Install the ca-certificates package (e.g., sudo apt install ca-certificates).
  • Permission denied: When saving to a system directory, run wget with sudo or save to a writable location like your home folder.
  • DNS resolution failure: If wget says “unable to resolve host address,” check your network connection and DNS settings with ping example.com.
  • Proxy issues: If you are behind a proxy, set the environment variables http_proxy and https_proxy before running wget.

wget vs. curl: Which Should You Use?

Both wget and curl are command-line downloaders, but they have different strengths. wget is designed for recursive downloads and mirroring, making it great for downloading entire websites. curl supports more protocols and is often used for API testing because it handles headers and POST requests easily. For simple file downloads, either works. If you are writing a script that needs to run on many systems, consider using curl because it is more commonly preinstalled on modern Linux distributions, especially on minimal servers.

How to Avoid This Error in the Future

When creating a new Linux system or container, include wget in the initial package installation. For Docker, add a line like RUN apt-get update && apt-get install -y wget to your Dockerfile. For cloud images, check the distribution’s documentation for the default package set. If you are building a custom minimal system, decide whether you need wget or if curl is sufficient, and install the one you choose.

Frequently Asked Questions

Is wget preinstalled on most Linux distributions?

Many desktop distributions include wget by default, but minimal installations, containers, and some lightweight distros like Alpine do not. It is always safe to check with which wget before relying on it.

Can I use wget on Windows or macOS?

Yes. Windows 10 and 11 include curl, but wget is not built-in. You can install it via Chocolatey or download the standalone executable. macOS does not include wget by default, but you can install it with Homebrew (brew install wget).

What is the difference between wget and curl for downloading a single file?

For a single file, both work. wget saves the file with the same name as the remote file by default, while curl requires the -O flag to do that. curl is more flexible with protocols and data transfer, but wget has simpler recursive download options.

How do I fix “wget: command not found” in a Docker container?

You need to install wget inside the container. For a Debian-based image, run apt-get update && apt-get install -y wget. For Alpine, use apk add wget. Alternatively, use curl if it is available.

Why does wget say “command not found” but curl works?

That simply means curl is installed and wget is not. You can either install wget or use curl as a substitute. Many systems ship with curl by default, especially in minimal environments.

Can I download a file without wget or curl?

Yes. You can use Python’s urllib, Perl’s LWP, or even a web browser. For scripting, Python is a good fallback if it is installed.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →