[Solved]: “wget command not found”
The wget is a command-line tool used for downloading files from the internet. The name “wget” stands for “web get.” It is available on most Unix-based operating systems, including Linux and macOS, and Windows through third-party software.
The wget command is an essential tool for downloading files from the internet using a command line interface. Sometimes, while using the wget command, the “wget command not found” error occurs. This post will list the possible reasons and the solutions to fix the error.
How to Fix the “wget command not Found” on Linux?
In the earlier Linux/mac versions, the wget utility did not come by default. So, if the user tried to use the wget command before using it, the error “wget command not found” was faced. The same is the case in the latest versions. Let’s dig into the reasons in more detail:
Most Linux distributions ask you for minimal or full installation at installation time. If you have chosen minimal, you might not be able to use wget, resulting “wget command not found” error.
Utility Not Installed
If the utility is deleted incidentally, you won’t be able to make the wget command, and the same error occurs.
Path Not Configured
You will get the same error if the utility is installed on your system and its executable’s oath is not configured.
Let’s have a look at how the error appears. In the following snippet, you can see that the wget command is being executed. However, the error “command not found” appears, which shows it is not installed:
Solution 1: Install the wget Utility
If the error occurs due to the absence (it could be a minimal installation or the utility not installed) of the wget utility, then you have to install it on your system. The commands to install the wget on various Linux distributions are as follows:
$ sudo apt install wget
$ sudo yum install wget
$ sudo dnf install wget
$ sudo pacman -S wget
Let’s execute the wget command to verify whether the error has been removed or not:
In our case, the simple installation has fixed the error. If you are still facing the error, then you have to follow the next solution; let’s dig into it and understand how it will
Solution 2: Add the wget Path
Any Linux command fetches the relevant data from the executable of the command. By default, the system searches inside the “/usr/bin/” directory for the command executable. If the executable is not at the “/usr/bin/” directory, the system throws the error “wget command not found” even if installed.
Therefore, it is necessary to look for the command’s path where it is installed, check if it is inside the “/usr/bin” path or not, and configure it accordingly. Let’s see how to do it:
Step 1: Get the Path of the wget
First, you need to locate the executable where it is installed via the command provided below:
$ which wget
This will show the path where its executable is available.
Step 2 (Optional): Add the Path
If the executable’s path is other than “/usr/bin/,” you must add that path in the “.bashrc” file. For this, open the “.bashrc” file:
$ sudo nano .bashrc
Now, add the following line at the end of the file. As the path in our case is “/usr/bin,” you need to replace the path with what you got in step 1:
$ export PATH="/usr/bin:$PATH"
Save and Exit out of the editor. Finally, use the following source command to apply the changes in the current environment:
$ source .bashrc
This will fix the “wget command not found error” on any Linux-based system.
The “wget command not found” error occurs if the command is not installed in your system or the system cannot locate the executable’s actual path. This error can be fixed by installing the wget command in your respective Linux distribution. If the simple installation has not fixed it for you, you must add the command’s executable in the “.bashrc” file so that system can locate the command.
This post has elaborated on the possible causes and the solutions to fix the error “wget command not found.” Keep visiting Linux-Genie for more troubleshooting guides.