Blog

How to Install Wget on CentOS 7

Wget is a popular utility just like its name – small and useful! The best thing is that Wget is open source, which means that not only can you use it to download files quickly over HTTP, HTTPS, and FTP, but can also study the source code in case you are curious.
However, on some CentOS 7 systems, wget might not be installed by default. If you type this, for example:

$ wget https://example.org/file.pdf

you will get this error:

bash: wget: command not found

Do not despair! The error message doesn't mean that you won't be able to use wget in your system. It just means that wget isn't installed by default.
And now for the really good news. Installing wget on CentOS 7 is a breeze. Make sure you are logged in as root (or use the sudo prefix) and do this:

# yum install wget

yum is the default package manager for CentOS 7, and once you execute the above command, yum will search for the wget package in its cloud repository and install it on your system.
During the install, you will be asked to confirm that you're okay with downloading wget. You will see a prompt like this:

Total download size: 483k
Total install size: 1.8M
Is this okay [y/N]:

At this prompt, just type 'y' and hit Enter. wget will then be installed on your system, and now you can enjoy downloading as much as you want.

Some handy tips on wget for CentOS 7

Many people are not aware of the hidden powers of wget, so we'll spend some time learning about the various capabilities it has. Note them down somewhere, because these will definitely come handy one day!

Downloading An Entire Website Using wget

wget can download an entire website in a single command! Yes, it's not only possible, but is very easy. Here's the command for it:

$ wget -r http://example.com

The '-r' option here signifies 'recursively', which means wget will keep walking through the entire website structure tree, scanning directories within directories, downloading their files, and then moving on to parent directories. Pretty neat, eh?

Resuming downloads with wget

What if downloading a large file but had to terminate the download for some reason? Was the partial download in vain? Not at all! wget can easily pick up the download where it left off. To accomplish this, simply issue the following command:

$ wget --continue http://example.com/centos-7-image.iso

Limit download speed with wget

If you're sharing the Internet bandwidth, it's a good idea not to consume the entire bandwidth on your download. You can tell wget to take it easy by using this command

$ wget --limit-rate=1000k http://example.com/centos-7-image.iso

And there you have it! In case you're intrigued and want to read more, just type 'wget -h' and read the manual pages that come installed with the package.