Skip to Content

2 new ways to fix wget: command not found

The error message “wget: command not found” is a common response you may encounter when attempting to run the wget command in your terminal or command prompt.

This error occurs when the system cannot find the wget command because it is not installed or not available in the system’s PATH..

Here’s what the error message means and some steps to resolve the issue:

  1. wget is not installed:
    The most straightforward reason for this error is that the wget tool is not installed on your system. wget is not a standard part of all operating systems, so you may need to install it separately.
  2. wget is not in the system’s PATH:
    Even if wget is installed, the system may not know where to find it. The PATH is a list of directories that the system searches for executable files like wget. If wget is not in one of these directories, you’ll encounter the “command not found” error.

 

 

How to install wget

Step 1: Check if Wget is installed

Before using wget, it’s essential to verify if it’s already installed on your system. Open your terminal or command prompt and type:

wget --version

If wget is installed, you will see its version information. If it’s not installed, you will likely get an error message stating that the command is not found.

Step 2: Install Wget (if not found)

The method to install wget depends on your operating system. Here are the installation steps for various systems:

Installation on Debian based systems (e.g., Ubuntu):

To install wget on Debian-based systems, you can use the package manager (apt):

sudo apt update

sudo apt install wget

Installation on Red Hat based systems (e.g., CentOS, Fedora):

On Red Hat-based systems, you can use the package manager (yum or dnf) for installation:

# For CentOS 6 and earlier or RHEL 6 and earlier

sudo yum install wget 

# For CentOS 8, CentOS 7, RHEL 8, RHEL 7, Fedora, etc.

sudo dnf install wget 

Installation on Windows:

For Windows users, wget is not pre-installed. However, you can download wget binaries and add them to your system’s PATH to use it from the Command Prompt. Here are the steps:

  • Visit the following website to download the wget binaries for Windows:https://eternallybored.org/misc/wget/
  • Download the appropriate version (32-bit or 64-bit) of wget.
  • Place the downloaded wget.exe file in a directory that is included in your system’s PATH (e.g.,C:\Windows).You can now use wget from the Command Prompt.

 

Installation on macOS:

On macOS, you can install wget using Homebrew, a popular package manager for macOS.

Here are the steps to install wget:

  • Install Homebrew (if not installed)
    If you don’t have Homebrew installed, you can install it by opening the Terminal and running the following command:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    Follow the prompts during the installation process, and Homebrew will be installed on your system. Get more details on official website.
  • Install wget using Homebrew
    After installing Homebrew, you can use it to install wget.
    Open the Terminal and run the following command:
    brew install wget
    Homebrew will download the wget package and its dependencies and install them on your macOS system.

 

Add wget to system PATH

Check the system’s PATH (Unix-like systems):

If wget is installed, but you’re still getting the error, it’s possible that the directory containing wget is not included in the system’s PATH.

You can check the PATH variable by running the following command:

echo $PATH

Ensure that the directory where wget is installed (e.g., /usr/bin or /usr/local/bin) is listed in the output.

If it’s not, you can add it to the PATH using the following command (replace /path/to/wget with the actual path to the wget executable):

export PATH="/path/to/wget:$PATH"

To make this change permanent, add the above line to your shell’s configuration file (e.g., ~/.bashrc or ~/.zshrc), and then restart your terminal.

Check the PATH environment variable on Windows 

If you installed wget on Windows, make sure you placed the wget executable in a directory that is included in the system’s PATH.

You can add the directory containing wget.exe to the PATH through the Windows System Properties > Advanced tab > Environment Variables.

Once you’ve installed wget and ensured it is in the PATH, you should be able to run wget commands without encountering the “command not found” error.

Wget Usage Examples

Once wget is installed, you can use it to download files from the internet. Here are some examples of wget usage:

Download a file:

wget <https://example.com/file.txt>

Save the downloaded file with a specific name:

wget -O output.txt <https://example.com/file.txt>

Download multiple files:

wget <https://example.com/file1.txt> <https://example.com/file2.txt>

Download recursively (useful for downloading entire directories):

wget -r <https://example.com/directory/>

Limit download speed (e.g., 1 MB/s):

wget --limit-rate=1m <https://example.com/file.txt>

Continue interrupted download:

wget -c <https://example.com/large_file.zip>

Conclusion

wget is a versatile command-line tool for downloading files from the internet. Before using it, make sure to check if it’s installed on your system.

If not, you can install it using the appropriate method for your operating system. Once installed, you can use wget with various options to download files and perform other tasks efficiently from the command line.