Friday, November 15, 2024
Google search engine
HomeGuest BlogsHow to Fix the “wget: command not found” Error

How to Fix the “wget: command not found” Error

Introduction

Wget is a command-line utility for retrieving files from the internet. Developers use the wget command to programmatically download web pages, PDFs, and XML sitemaps and interact with REST API endpoints.

Wget is included as a default package in most Linux distributions. The wget: command not found error appears when the Wget tool is not installed.

Learn how to install Wget on Ubuntu, Debian, Fedora, or Rocky Linux and fix the wget: command not found error.

Developer using the wget command to fetch a file.Developer using the wget command to fetch a file.

Prerequisites

  • Access to a command line/terminal window.
  • A user account with sudo or root privileges.

Check if Wget is Installed

To verify the Wget utility is installed, open a terminal and type wget without entering a URL:

sudo wget

Note: This command is applicable across Linux distributions.

If Wget is present, the system responds with the wget: missing URL usage message.

The wget usage message in Linux.The wget usage message in Linux.

The wget: command not found error is displayed if Wget is not installed.

The wget command not found error message.The wget command not found error message.

To resolve the issue, you need to install Wget on your system.

Install Wget

Follow the instructions for the Linux distribution you currently use to install Wget.

Install Wget on Ubuntu/Debian

Before installing Wget on Debian-based Linux distributions such as Ubuntu 22.04 or Debian 11, update the apt package lists using the following command:

sudo apt update
Update apt package lists in Ubuntu.Update apt package lists in Ubuntu.

Use the apt command to install Wget:

sudo apt install wget
Installing wget on Ubuntu.Installing wget on Ubuntu.

Once the installation is complete, check the Wget utility version:

sudo wget --version

In this example, the GNU Wget version is 1.21.2.

Check wget version in Ubuntu.Check wget version in Ubuntu.

Check the path to the Wget installation directory using the following command:

sudo which wget
Locate wget installation folder in Ubuntu.Locate wget installation folder in Ubuntu.

Install wget on Rocky/Fedora

To install Wget on RHEL-based Linux distributions, such as Fedora or Rocky Linux, enter the following command:

sudo dnf install wget -y
Installing wget on Fedora and Rocky Linux.Installing wget on Fedora and Rocky Linux.

The version of the installed Wget utility is displayed in the terminal.

The installed wget version in Rocky Linux.The installed wget version in Rocky Linux.

The Complete! message indicates that Wget is installed.

The wget installation on Rocky Linux or Fedora is complete.The wget installation on Rocky Linux or Fedora is complete.

Use the sudo which wget command to check the installation directory path:

sudo which wget
The wget installation directory in Rocky Linux.The wget installation directory in Rocky Linux.

Conclusion

You have successfully installed Wget and resolved the wget: command not found error. Wget supports recursive downloads, allowing developers to retrieve initially requested documents and linked documents sequentially, preserving the interconnections within the content.

Explore our starter guide on wget commands with examples and learn how to incorporate Wget in scripts and cron jobs to automate file downloads.

Was this article helpful?
YesNo

RELATED ARTICLES

Most Popular

Recent Comments