Blog

03/06/2019

How to install wget on RHEL/CentOS 7 using yum



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.

How to use yum to install wget command

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

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://sxi.io/files/adduser.txt
Sample outputs:

--2016-11-22 08:45:26--  https://sxi.io/files/adduser.txt
Resolving sxi.io (sxi.io)... 75.126.153.202
Connecting to sxi.io (sxi.io)|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.sxi.io: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.sxi.io:3128/
http_proxy = http://server1.sxi.io:3128/
ftp_proxy = http://server1.sxi.io:3128/
 
# Setup the credentials for both http/ftp
user=vivek
password=OhMyCoolPasswordHere
See also:
This entry is 4 of 5 in the Linux/Unix install wget Tutorial series. Keep reading the rest of the series:
  1. Freebsd Install wget Utility To Download Files From The Internet
  2. How to install wget on RHEL 8 using the dnf command
  3. How to install wget on a Debian or Ubuntu Linux
  4. How to install wget on RHEL/CentOS 7 using yum
  5. Mac OS X Sierra Install wget Network Downloader Utility

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....
12/08/2019

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...