YouTube Icon

Code Playground.

Wget Command in Linux with Examples


Wget Command in Linux with Examples

GNU Wget is an order line utility for downloading records from the web. With Wget, you can download records utilizing HTTP, HTTPS, and FTP conventions. Wget gives various choices permitting you to download numerous documents, continue downloads, limit the data transfer capacity, recursive downloads, download out of sight, reflect a site, and substantially more. 

This article tells the best way to utilize the wget order through useful models and point by point clarifications of the most widely recognized alternatives. 

Installing Wget

The wget bundle is pre-introduced on most Linux dispersions today. 

To check whether the Wget bundle is introduced on your framework, open up your reassure, type wget, and press enter. In the event that you have wget introduced, the framework will print wget: missing URL. Else, it will print wget order not found. 

In the event that wget isn't introduced, you can without much of a stretch introduce it utilizing the bundle administrator of your distro. 

Installing Wget on Ubuntu and Debian

sudo apt install wget

Installing Wget on CentOS and Fedora

sudo yum install wget

Wget Command Syntax

Prior to going into how to utilize the wget order, we should begin by exploring the essential linguistic structure. 

The wget utility articulations take the accompanying structure: 

wget [options] [url]

alternatives - The Wget choices 

url - URL of the document or catalog you need to download or synchronize. 

How to Download a File with wget

In its easiest structure, when utilized with no choice, wget will download the asset determined in the [url] to the current catalog. 

In the accompanying model, we are downloading the Linux piece tar chronicle: 


wget download record 

As should be obvious from the picture above, wget begins by settling the area's IP address, at that point associates with the far off worker and starts the exchange. 

During the download, wget shows the advancement bar close by the record name, document size, download speed, and the assessed time to finish the download. Once the download is finished, you can discover the downloaded record in your present working registry . 

To kill the yield, utilize the - q alternative. 

In the event that the record as of now exists, wget will add .N (number) toward the finish of the document name. 

Saving the Downloaded File Under Different Name

To save the downloaded document under an alternate name, pass the - O choice followed by the picked name: 

wget -O

The order above will save the most recent hugo compress record from GitHub as most recent rather than its unique name. 

Downloading a File to a Specific Directory

Naturally, wget will save the downloaded document in the current working index. To save the record to a particular area, utilize the - P choice: 

wget -P /mnt/iso

The order above advises wget to save the CentOS 7 iso document to the/mnt/iso registry. 

Limiting the Download Speed

To restrict the download speed, utilize the - limit-rate alternative. As a matter of course, the speed is estimated in bytes/second. Attach k for kilobytes, m for megabytes, and g for gigabytes. 

The accompanying order will download the Go paired and cutoff the download speed to 1MB: 

wget --limit-rate=1m

This alternative is valuable when you don't need wget to burn-through all the accessible data transfer capacity. 

Resuming a Download

You can continue a download utilizing the - c choice. This is valuable if your association drops during a download of an enormous record, and as opposed to beginning the download without any preparation, you can proceed with the past one. 

In the accompanying model, we are continuing the download of the Ubuntu 18.04 iso document: 

wget -c

On the off chance that the distant worker doesn't uphold continuing downloads, wget will begin the download from the earliest starting point and overwrite the current record. 

Downloading in Background

To download out of sight, utilize the - b choice. In the accompanying model, we are downloading the OpenSuse iso record out of sight: 

wget -b

As a matter of course, the yield is diverted to wget-log document in the current registry. To watch the status of the download, utilize the tail order: 

tail -f wget-log

Changing the Wget User-Agent

Now and then while downloading a document, the distant worker might be set to obstruct the Wget User-Agent. In circumstances like this, to imitate an alternate program, pass the - U choice. 

wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"

The order above will copy Firefox 60 mentioning the page from 

Downloading Multiple Files

On the off chance that you need to download various records immediately, utilize the - I alternative followed by the way to a neighborhood or outer document containing a rundown of the URLs to be downloaded. Every URL should be on a different line. 

The accompanying model tells the best way to download the Arch Linux, Debian, and Fedora iso documents utilizing the URLs determined in the linux-distros.txt record: 

wget -i linux-distros.txt


On the off chance that you determine - as a filename, URLs will be perused from the standard information. 

Downloading via FTP

To download a record from a secret key ensured FTP worker, indicate the username and secret phrase as demonstrated as follows: 

wget --ftp-user=FTP_USERNAME --ftp-password=FTP_PASSWORD

Creating a Mirror of a Website

To make a reflection of a site with wget, utilize the - m choice. This will make a total neighborhood duplicate of the site by following and downloading all inside connections just as the site assets (JavaScript, CSS, Images). 

wget -m

In the event that you need to utilize the downloaded site for nearby perusing, you should pass a couple of additional contentions to the order above. 

wget -m -k -p

The - k alternative will cause wget to change the connections in the downloaded archives over to make them reasonable for neighborhood seeing. The - p choice will advise wget to download all important records for showing the HTML page. 

Skipping Certificate Check

In the event that you need to download a document over HTTPS from a host that has an invalid SSL authentication, utilize the - no-registration choice: 

wget --no-check-certificate

Downloading to the Standard Output

In the accompanying model, wget will discreetly ( banner - q) download and yield the most recent WordPress rendition to stdout ( banner - O - ) and pipe it to the tar utility, which will separate the document to the/var/www catalog. 

wget -q -O - "" | tar -xzf - -C /var/www


With wget, you can download numerous records, continue incomplete downloads, reflect sites, and join the Wget choices as per your necessities. 

To study Wget, visit the GNU wget Manual page.