How to install wget on RHEL/CentOS 7 using yum

Posted on in Categories , , , , , last updated November 22, 2016

I am trying to download a file using ‘wget http://url’ syntax, but I am getting an error:

bash: wget: command not found

How do I fix this problem? How can I install wget on a CentOS/RHEL 7 or 6 server using yum command?

GNU Wget is a free and open source software package for retrieving files using HTTP, HTTPS, and FTP, the most widely-used Internet protocols. The GNU/wget might not be installed on your system and here is how to install it using yum command.

Use yum to install wget

Open the Terminal application or login using ssh client and type the following command to install wget on CentOS/RHEL 5/6/7:
$ sudo yum install wget
Sample outputs:

Fig.01: Installing GNU/wget on CentOS/RHEL using yum command
Fig.01: Installing GNU/wget on CentOS/RHEL using yum command

A note about Fedora Linux users

Use the following syntax to install wget on Fedora 24:
$ sudo dnf install wget

How do I use wget?

The syntax is:
wget url
wget [options] http://url
wget [options] ftp://url

Usage and examples

To download a file from the internet, enter:
$ wget https://www.cyberciti.biz/files/adduser.txt
Sample outputs:

--2016-11-22 08:45:26--  https://www.cyberciti.biz/files/adduser.txt
Resolving www.cyberciti.biz (www.cyberciti.biz)... 75.126.153.202
Connecting to www.cyberciti.biz (www.cyberciti.biz)|75.126.153.202|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1022 [text/plain]
Saving to: 'adduser.txt'
 
100%[======================================>] 1,022       --.-K/s   in 0s      
 
2016-11-22 08:45:27 (59.4 MB/s) - 'adduser.txt' saved [1022/1022]

To use the wget with proxy authentication, enter:
$ export https_proxy="https://server1.cyberciti.biz:3128/"
$ wget --proxy-user "USERNameHere" --proxy-password "PASSWORDHere" http://url-here

To use wget with a username and password for FTP / HTTP file retrieval, use:
$ wget --user=NAME --password='PASSWORD' url
To download a large file in size in background, enter:
$ wget -bqc http://path-to-freebsd-mirros-url/freebsd-lastest.iso
You
can resume broken download with wget using the following syntax:
$ wget -c http://url/large.file.tar.gz
$ wget --continue https://url/file.iso

Anther usage is to archive a website using wget:
$ wget -nprk 'https://www.some-url-here/'

Creating ~/.wgetrc file

The $HOME/.wgetrc file act as an initialization file for GNU wget. You can store option in it. Here is my sample $HOME/.wgetrc file:

# sample file 
# Try ipv6 addresses first
prefer-family = IPv6
 
# Setup proxy
https_proxy = http://server1.cyberciti.biz:3128/
http_proxy = http://server1.cyberciti.biz:3128/
ftp_proxy = http://server1.cyberciti.biz:3128/
 
# Setup the credentials for both http/ftp
user=vivek
password=OhMyCoolPasswordHere
See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 1 comments/add one below):

1 comment

Leave a Comment