wget Command Examples in Linux

The wget command is one of the most popular non-interactive command-line file downloaders in Linux. It can download multiple files/directories and can work in the background as well. The downloaded web page can be opened with any graphical or non-graphical browser.

Some of its popular features are as follows:

  • Support of HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies
  • Resume partial downloads
  • Large file downloads
  • Recursive downloads for mirroring a website
  • Password-required downloads

Syntax:

$ wget [url]

To install Wget on Debian and Ubuntu-based systems, run the following command. There is a significant chance that it’s already installed thanks to its popularity:

# apt-get install wget

To install Wget on Red Hat derivatives use the following command:

# yum install wget

wget Command Examples

1. To download a page:

# wget www.linux.com

2. To log messages:

# wget -o log www.thegeekdiary.com

3. To append to log file:

# wget -a log www.thegeekdiary.com

4. To run in background:

# wget -b  -o log www.thegeekdiary.com

5. To run in verbose mode:

# wget -v -o log www.thegeekdiary.com

6. To run in quite mode:

# wget -q -o log www.thegeekdiary.com

7. To read URLs from file:

# wget -i urlfile -o log www.thegeekdiary.com

8. To set number of tries:

# wget -t 5 -o log www.thegeekdiary.com

9. To see the progress:

# wget --progress=type -o log www.thegeekdiary.com type=bar
# wget --progress=type -o log www.thegeekdiary.com type=dot

10. To turn on time stamping:

# wget -N -o log www.thegeekdiary.com

11. To print the headers sent by the HTTP server/FTP server:

# wget -S -o log www.thegeekdiary.com

12. To check the pages are there or they are available:

# wget --spider -i urlfile

13. To set the time-out period:

# wget -T 60 -o log www.thegeekdiary.com

14. To limit the download speed:

# wget --limit-rate 100K -o log www.thegeekdiary.com

15. To specify the interval between downloads:

# wget -w 10 -o log -i urlfile

16. To display the version of wget:

# wget -V
# wget --version

Final Thoughts

You may find it useful to download a copy of a website for local examination and to use it to run other tests on. If this is something you wish to do, the easiest and simplest way is to use the wget command, which is a standard Linux tool used to retrieve information from websites. The wget utility is a non-interactive downloader.

Related Post