wget command not found [SOLVED]


Omer Cakmak

Tips and Tricks

wget is a command line download manager that allows downloading files over the internet using protocols such as HTTP, HTTPS, FTP. wget's name is derived from the World Wide Web and get.

When you want to use wget, you may encounter the "wget command not found" problem. In this article you will find solutions for this problem.

 

Solutions for "wget command not found"

There may be several solutions to this problem. Now let's talk about these in turn.

 

Solution-1: wget package may not be installed

Of course, wget does not come pre-installed on every operating system. You can check whether it is installed on your operating system with the following commands.

On Debian based operating systems such as Ubuntu, Mint and Pardus:

$ sudo dpkg -l | grep wget
ii  wget                                  1.21.2-2ubuntu1                         amd64        retrieves files from the web

On Redhat based operating systems such as Rocky Linux, AlmaLinux and Centos:

$ sudo dnf list installed | grep wget
wget.x86_64                                       1.21.3-1.fc35                           @updates

On Arch Linux based operating systems such as Manjaro, Archman:

[manjaro ~]# sudo pacman -Q | grep wget
wget 1.21.3-1

If the wget package is not installed on your system, you can find the installation steps for different distributions below.

To install wget on Debian-based operating systems such as Ubuntu, Mint and Pardus:

sudo apt install wget -y

To install wget on Redhat-based operating systems such as Rocky Linux, AlmaLinux, and Centos:

sudo dnf install wget -y

To install wget on Arch Linux based operating systems such as Manjaro, Archman:

sudo pacman -S wget

After installing wget, in terminal to use;

Usage: wget [OPTION]... [URL]...

After the wget command, type the url information of the item you want to download. Then the download will start.

 

Solution-2: PATH environment variable may be incorrect

PATH is the system variable that the operating system uses to locate executables from the command line or terminal.

When the PATH variable is configured incorrectly or incompletely by the user, you will encounter this error even if wget is installed on the system.

The wget command is called from /bin/wget on the system:

foc@ubuntu22:~$ /bin/wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Many commands, including wget, will not work if /bin is not in the user PATH variable. You can see the PATH variable like this:

foc@ubuntu22:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

As you can see, there are /bin statements in the variable definition. If you have a PATH variable like this:

foc@ubuntu22:~$ echo $PATH
/usr/local/games:/snap/bin:/usr/games

If you download with wget, you will get the error "wget: command not found" as follows:

foc@ubuntu22:~$ wget https://www.golinuxcloud.com/wp-content/uploads/Screenshot-from-2023-01-16-21-55-54-768x430.jpg
Command 'wget' is available in the following places
 * /bin/wget
 * /usr/bin/wget
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
wget: command not found

For solution, add /bin path with export command:

foc@ubuntu22:~$ export PATH=$PATH:/bin:/usr/bin

The final state of the PATH variable was:

foc@ubuntu22:~$ echo $PATH
/usr/local/games:/snap/bin:/usr/games:/bin:/usr/bin

Now download again with wget:

foc@ubuntu22:~$ wget https://www.golinuxcloud.com/wp-content/uploads/Screenshot-from-2023-01-16-21-55-54-768x430.jpg
--2023-02-03 22:13:54--  https://www.golinuxcloud.com/wp-content/uploads/Screenshot-from-2023-01-16-21-55-54-768x430.jpg
Resolving www.golinuxcloud.com (www.golinuxcloud.com)... 104.19.154.92, 104.19.155.92, 2606:4700::6813:9a5c, ...
Connecting to www.golinuxcloud.com (www.golinuxcloud.com)|104.19.154.92|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 141360 (138K) [image/jpeg]
Saving to: ‘Screenshot-from-2023-01-16-21-55-54-768x430.jpg’

Screenshot-from-2 100%[=============>] 138.05K  --.-KB/s    in 0.03s   

2023-02-03 22:13:55 (4.30 MB/s) - ‘Screenshot-from-2023-01-16-21-55-54-768x430.jpg’ saved [141360/141360]

The download was done successfully.

But the changes are not persistent across reboot, so for permanent changes you can place the export command inside .bashrc file of user's home directory. Read more at .bashrc vs .bash_profile [Which one to use?]

 

What is NEXT?

15+ wget command examples in Linux [Cheat Sheet]
Tips to download file From Linux [Practical Examples]

Summary

wget is used for a single job as well as in bash scripts. Sometimes it can also be used to control the system's access to a file.

In this article, we have provided solutions for the "wget: command not found" error. We hope this article has solved your problem.

 

References

stackoverflow.com - wget command not found on linux server 

 

Views: 12

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on LinkedIn or check his projects on GitHub page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment

GoLinuxCloud Logo


We try to offer easy-to-follow guides and tips on various topics such as Linux, Cloud Computing, Programming Languages, Ethical Hacking and much more.

Programming Languages

JavaScript

Python

Golang

Node.js

Java

Laravel