If you’re encountering the “wget: command not found” error, it means that the wget
command-line utility is not installed or not accessible in your system. In this article, we will explain how to solve this issue quickly.
Table of Contents
wget:command not found – how to fix in CentOS
To install wget
on CentOS, you can use the yum
package manager. Here’s how you can install wget
on CentOS:
- Open a terminal or SSH into your CentOS system.
- Run the following command as the root user or a user with sudo privileges:
sudo yum install wget
This command will prompt you to confirm the installation by typing ‘y’ and pressing Enter. If prompted, enter your password to authenticate the installation.
yum
will then download and install the wget
package along with any required dependencies.
Once the installation is complete, you should be able to use the wget
command to download files from the command line. You can test it by running:
wget --version
That verifies that wget
is now installed on your CentOS system. That will fix wget command not found error.
wget:command not found – how to fix in Ubuntu
In Ubuntu, you can install wget
using the apt-get
package manager. Here’s how you can install wget
on Ubuntu:
Open a terminal on your Ubuntu system. You can do this by pressing Ctrl+Alt+T.
Run the following command:
sudo apt-get update
This command updates the package lists to ensure you have the latest information about available packages.
After the update is completed, run the following command to install wget
:
sudo apt-get install wget
This command will prompt you to confirm the installation by typing ‘y’ and pressing Enter. If prompted, enter your password to authenticate the installation.
apt-get
will then download and install the wget
package along with any required dependencies.
Once the installation is complete, you should be able to use the wget
command to download files from the command line. You can test it by running:
<code>wget --version</code>
to verify that wget
is now installed on your Ubuntu system.
And that’s another fix for the wget command not found error, in Ubuntu Linux.
Fixing wget issue by updating system’s PATH
If wget is already installed but not accessible, you may need to update your system’s PATH environment variable to include the location of the wget executable.
You can do this by adding the following line to your shell’s configuration file (e.g., ~/.bashrc
or ~/.bash_profile
):bash
export PATH="/usr/bin:/usr/local/bin:$PATH"
Save the file and then restart your shell or run source ~/.bashrc
(or source ~/.bash_profile
) to apply the changes.
What causes the wget command not found issue?
The “wget command not found” issue can occur on any Linux system if the wget
command-line utility is not installed or not accessible.
There can be a few reasons for this error:
- Package not installed: The
wget
package might not be installed on the system. This can happen if the system is minimal or if the package was not included during the initial installation. - PATH environment variable: The
wget
executable might not be in the system’s PATH environment variable. This means the system doesn’t know where to find thewget
command when it’s executed. - Limited user permissions: The user running the command may not have sufficient permissions to access or execute the
wget
command.
To fix the “wget command not found” issue, you can follow the steps mentioned in this article to install wget
using the appropriate package manager for your Linux distribution.
How to fix in other OS’es?
It’s worth noting that some minimal or specialized Linux distributions may not have wget
available in their default package repositories. In such cases, you might need to use alternative methods to download files, such as using curl
or manually installing wget
from other sources.
Install wget: Use the package manager specific to your operating system to install wget. Here are the commands for some popular package managers:
For Ubuntu/Debian-based systems:
<code>sudo apt-get install wget</code>
For CentOS/Fedora-based systems:
<code>sudo yum install wget</code>
For Homebrew on macOS:
<code>brew install wget</code>
What is the wget command?
The wget
command is a popular command-line utility used for retrieving files from the web. It stands for “Web Get” and is commonly available on Unix-like systems, including Linux.
The basic syntax of the wget
command is as follows:
wget [options] [URL]
Here, [options]
represents various command-line options that modify the behavior of wget
, and [URL]
is the web address (URL) of the file you want to download.
Some common options and use cases of wget
include:
Downloading a file: You can simply provide the URL of the file you want to download, and wget
will retrieve it. For example:
wget http://example.com/file.txt
Specifying output filename: By default, wget
saves the downloaded file with its original name. You can use the -O
option to specify a different output filename. For example:
wget -O output.txt http://example.com/file.txt
Recursive downloading: wget
can recursively download files, allowing you to retrieve an entire directory or website. The -r
option is used for recursive downloading. For example:
wget -r http://example.com/directory/
Resuming interrupted downloads: If a download is interrupted, wget
can resume it from where it left off using the -c
option. For example:
<code>wget -c http://example.com/largefile.zip</code>
These are just a few examples of the capabilities of the wget
command. wget
provides many more options and features, allowing you to customize the download process according to your needs. You can refer to the wget
manual or documentation for a comprehensive list of options and their usage.
What are the wget compatible OS where the error wget command not found can occur?
Here are some additional details about the availability and usage of the wget
command in different operating systems:
- Linux:
wget
is widely available and commonly used on various Linux distributions. It is often included by default or can be installed easily using package managers likeapt
,yum
, ordnf
. Linux users rely onwget
for downloading files from the web, recursive downloads, resuming interrupted downloads, and more. - macOS:
wget
is not included as a preinstalled command on macOS. However, macOS users can install it using package managers like Homebrew or MacPorts. Homebrew is a popular choice for macOS users to install and manage command-line utilities, includingwget
. Once installed,wget
functions similarly to its usage on Linux systems. - Unix-like systems: Apart from Linux and macOS,
wget
is available and commonly used on various Unix-like systems. This includes FreeBSD, OpenBSD, and Solaris, where users can typically installwget
using package managers specific to those operating systems. - Windows: While
wget
is primarily associated with Unix-like systems, there are also ports ofwget
available for Windows. These ports provide the functionality of thewget
command-line utility on Windows systems. Examples of Windows ports include GNU Wget for Windows (also known as GnuWin32) and Wget for Windows (native Windows port). Users can download and install these ports to usewget
commands within a Windows command prompt or PowerShell.
It’s important to note that the usage and behavior of wget
commands are generally consistent across different operating systems once the utility is installed. However, installation methods may vary depending on the specific operating system or package manager used.
How to check if wget command is corrupted?
To check if the wget command is corrupted, you can follow these steps:
Open a terminal on your Linux system.Run the which wget command to determine the location of the wget executable. This command will display the path to the wget binary.
which wget
If the wget command is properly installed and accessible, it will output the path to the wget executable (e.g., /usr/bin/wget).
Once you have the path to the wget executable, you can verify its integrity by running the file command followed by the path to the wget binary.
file /usr/bin/wget
The file command examines the file type and content. It will provide information about the wget binary, confirming whether it appears to be a valid executable file.
If the output indicates that the file is a dynamically linked executable (ELF), it suggests that the wget command is likely not corrupted. However, if the output indicates an unexpected file type or mentions “broken” or “corrupted,” it may indicate an issue with the wget binary.
If you suspect that the wget command is indeed corrupted, you can try reinstalling it using the appropriate package manager for your Linux distribution. Reinstallation typically resolves issues with corrupted binaries.
Alternative commands, different than wget
There are alternative commands to wget
that offer similar functionality for downloading files from the web. An alternative way to fix the wget command not found issue, is using a different tool to download files.
Here are a few popular alternatives:
curl
:curl
is a versatile command-line tool available on various operating systems, including Linux, macOS, and Windows. It supports downloading files using various protocols (HTTP, FTP, etc.) and offers extensive features and options. For basic file downloads, you can usecurl -O <URL>
.fetch
:fetch
is a command-line utility commonly found on BSD-based systems, including FreeBSD and macOS. It is designed specifically for file retrieval and can handle FTP and HTTP protocols. To download a file usingfetch
, you can use the commandfetch <URL>
.aria2
:aria2
is a powerful command-line download manager that supports parallel and segmented downloading. It can download files over HTTP, FTP, BitTorrent, and more.aria2
is available on various operating systems, including Linux, macOS, and Windows. The basic usage isaria2c <URL>
.wget2
:wget2
is an alternative version ofwget
that aims to provide additional features and improvements over the originalwget
. It offers enhanced performance, parallel downloading, and improved support for protocols.wget2
is still in development and may not be as widely available aswget
or the other alternatives.- scp: scp command is used to transfer files or directories from a server to another.
These alternative commands provide similar functionality to wget
and may offer additional features or improvements in certain cases. The choice of command depends on the specific requirements and preferences of the user and the availability of the tool on the operating system being used.