Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email
Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

wget Command in Linux Unix

Last Updated on November 24, 2023 by Abhishek Sharma

In the world of Unix and Linux, efficiency is paramount, and the wget command is a shining example of a tool designed to streamline the process of fetching data from the web. Whether you’re a seasoned sysadmin, a developer, or a curious enthusiast, wget is a versatile and indispensable utility. In this article, we’ll delve into the world of wget and explore its myriad applications. From simple file downloads to recursive website mirroring and everything in between, wget is your gateway to retrieving data effortlessly and automating tasks in Unix and Linux environments.

What is wget Command in Linux Unix?

wget is a versatile command-line utility in Unix and Linux that stands for "web get." It allows users to retrieve data from the internet using the HTTP, HTTPS, and FTP protocols. wget is a powerful tool designed for fetching files, mirroring websites, and automating data retrieval tasks. Below, we explore its key features and provide practical examples to illustrate its capabilities.

Key Features of wget Command in Linux Unix

Below are some key features of wget command in Linux Unix:

1. File Retrieval: wget excels at downloading individual files from the web. It can fetch resources from HTTP, HTTPS, and FTP servers. You can simply provide the URL of the file you wish to download.


2. Recursive Downloading: One of wget’s most powerful features is its ability to recursively download entire directories or websites. By using the -r option, you can mirror an entire website, including linked resources.

wget -r -np

3. Continued Downloads: wget allows you to resume interrupted downloads. If a connection is lost, or the download is paused, you can use the -c option to continue the download from where it left off.

wget -c

4. Limiting Download Speed: You can control the download speed with the –limit-rate option. For instance, to limit the download speed to 100 KB/s:

wget --limit-rate=100k

5. User Authentication: If a resource requires user authentication, wget can handle it with the –user and –password options.

wget --user=username --password=password

6. Custom Output Names: By using the -O option, you can specify a custom output file name for the downloaded resource.

wget -O mydocument.pdf

7. Logging: wget provides detailed logging capabilities to keep track of the download process. Use the -o option to direct the log output to a file.

wget -o download.log

8. HTTP Referer and User-Agent: You can set the HTTP Referer and User-Agent headers to mimic a particular web browser or source using the –referer and –user-agent options.

wget --referer= --user-agent="Mozilla/5.0"

Example: Basic File Download
Let’s download a sample text file using wget:


This command will retrieve the "sample.txt" file from the specified URL and save it to the current directory.

Example: Website Mirroring
To mirror a website with its linked resources, use the -r and -np options (which ensures that you don’t ascend to the parent directory):

wget -r -np

This command will create a local copy of the website, preserving its directory structure and downloading linked resources.

Example: Resuming an Interrupted Download
If a download was interrupted, you can resume it with the -c option:

wget -c

wget will continue downloading the file from where it was paused.

Example: Download Speed Limitation
To limit the download speed to 500 KB/s, use the –limit-rate option:

wget --limit-rate=500k

This command restricts the download speed to 500 KB/s for the specified file.

In the Unix and Linux ecosystem, the wget command stands as a testament to the power of simplicity. Its ability to effortlessly retrieve data from the web, combined with its flexibility and automation potential, makes it an essential tool in any user’s toolkit. Whether you are acquiring files, mirroring websites, or automating tasks, wget streamlines the process, allowing you to be more efficient and productive.

As we conclude our journey through the capabilities of wget, we hope you have gained a deeper understanding of its potential. From basic usage to advanced scripting, wget empowers users to access data from the web with ease. Its reliability, versatility, and cross-platform availability make it a trusted companion for a wide range of tasks.

As you continue to explore Unix and Linux, remember that wget is just one of the many tools at your disposal. The command-line environment offers a wealth of resources waiting to be harnessed. With wget in your arsenal, you are better equipped to navigate the complexities of data retrieval and automation.

FAQ (Frequently Asked Questions) Related to wget command in linux unix:

Here are some FAQs related to wget command in linux unix.

1. What is wget in Unix and Linux?
wget is a command-line utility that allows users to retrieve files and data from the web. It can be used to download single files, entire websites, or even mirror websites for offline browsing.

2. How do I use wget to download a file from the internet?
To download a file using wget, you can simply run the command followed by the URL of the file you wish to retrieve. For example: wget

3. Can wget be used to download entire websites?
Yes, wget can be used to recursively download an entire website, including its linked resources (e.g., images, stylesheets, and scripts) using the -r option.

4. What are some common use cases for wget?
Common use cases for wget include downloading files, creating backups of websites, automating data retrieval tasks, and fetching data for scripting and programming.

5. Can I limit the download speed with wget?
Yes, you can limit the download speed with wget by using the –limit-rate option.
For example,

wget --limit-rate=100k limits the download speed to 100 KB/s.

6. Is wget available on other operating systems besides Unix and Linux?
Yes, wget is available on various operating systems, including Unix, Linux, macOS, and Windows. It’s a versatile and cross-platform tool for web data retrieval.

7. Can wget be integrated into scripts and automation tasks?
Absolutely. wget is commonly used in scripts and automation tasks to retrieve data from the web automatically. It offers a wide range of options and customizability for scripting purposes.

Leave a Reply

Your email address will not be published. Required fields are marked *