Quick Tutorial: wget Command in Linux

wget command is basically a Linux utility used to get information and files from the web servers. This computer utility was developed by the GNU project. It extracts information via FTP, SFTP, HTTP, and HTTPS protocols. This Quick Tutorial explains the installation and example usage of wget command in Linux.

Installation

wget utility is generally preinstalled on most Linux distributions. To check whether wget is installed on your Linux distribution or not, just type wget on the terminal screen.

If you get the message, "wget: missing URL", that simply means it is preinstalled on your Linux distribution.

But if you get the message, "wget command not found" that means you need to install it on your distro.

On Ubuntu and Debian,

sudo apt install wget

On CentOS and Fedora,

sudo yum install wget

How to use wget command effectively?

wget utility comes with huge options to use this command very effectively. Below is the list of usage examples that can be used against the target.

Examples

(1) Basic Example

If you shoot the below command against any website, it will download the home page of that site.

wget https://allabouttesting.org

(2) Download specific files from the website

You can also use this command to download files in different formats available on the server/website. You just need to give the URL of that particular file.

wget https://allabouttesting.org/wp-content/uploads/2021/04/Load-Balancer-Security-Checklist-for-Security-Auditors.pdf 

(3) To create a mirror image of the website

By using the -m option allows mirroring the site in the directory.

wget -m https://allabouttesting.org

(4) Download the entire site

By using the below command, you can easily download the whole website in one command

wget -r -l 1 -p https://allabouttesting.org

-r : recursive download

-l : recursive depth

-p : for all images

(5) Save the download file with a different name

By using -O option that allows saving of file with a different name

wget -O newtest.zip https://<url>/test.zip

(6) Download multiple files with a single command

You can download multiple files by using -i option

wget -i urllist.txt

(7) Disable certificate check

wget checks certificate whenever retrieves data from the web. Bu using --no-check-certificate, wget ignore checking of valid certificate.

wget --no-check-certificate <url>

(8) Download file to the specific directory

By using -P option, you can download file and store in specific directory

wget -P /test https://allabouttesting.org

Help option

wget displays a nice manual to refer to by using the below command

wget -h

Conclusion

This blog provides a guide for installation and also illustrates example usage of wget command. This command is extremely useful and you are able to do most of the tasks just with the command line if you know this utility well.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

Your email address will not be published.