Read in 6 minutes

last updated 

Wget Command Examples

In this tutorial, we will show you how to use the Wget utility through practical examples and detailed explanations of the most common Wget options.

What is Wget?

GNU Wget is command line utility for downloading files from the web. With Wget you can download files using HTTP, HTTPS, and FTP protocols. Wget provides a number of options allowing you to download multiple files, resume downloads, limit the bandwidth, recursive downloads, download in a background, mirror a website and much more.

Install Wget

The wget package is pre-installed on most Linux distributions today.

To check whether the Wget package is installed on your system, open up your console, type wget and press enter. If you have wget installed the system will print wget: missing URL, otherwise it will print wget command not found.

If Wget is not installed you can easily install it using the package manager of your distro.

Install Wget on Ubuntu and Debian

sudo apt install wget

Install Wget on CentOS and Fedora

sudo yum install wget

Wget Command Syntax

Before going into how to use the wget command, let’s start by reviewing the basic syntax.

The wget utility expressions take the following form:

wget [options] [url]
  • options - The Wget options
  • url - URL of the file or directory you want to download or synchronize

How to download a file with

In it’s simplest form when used without any option, wget will download the resource specified in the [url] to the current directory.

In the following example we are downloading the Linux kernel tar archive:


As you can see from the image above wget starts by resolving the IP address of the domain, then connects to the remote server and starts the transfer.

During the download, wget shows the progress bar alongside with the file name, file size, download speed and the estimated time to complete the download. Once the download is complete you can find the downloaded file in your current working directory.

To turn off Wget’s output use the -q flag.

If the file already exists Wget will add .N (number) at the end of the file name.


How to save the downloaded file under different name

To change the name of the downloaded file you’ll need to pass the -O flag:

wget -O

The command above will save the latest hugo zip file from GitHub as

How to download a file to a specific directory

By default Wget will save the downloaded file in the current working directory. To save the file to a specific location you would use the -P flag:

wget -P /mnt/iso

With the command above we are telling Wget to save the CentOS iso file to the /mnt/iso directory.

How to limit the download speed

To limit the download speed use the --limit-rate flag. The value can be expressed in bytes, kilobytes with the k suffix and megabytes with the m suffix.

The following command will download the Go binary and limit the download speed to 1mb:

wget --limit-rate=1m

This option is useful when you don’t want Wget to consume all the available bandwidth.

How to resume a download

You can resume a download by using the -c flag. This is useful if your connection drops during a download of a large file and instead of staring the download from scratch you can continue the previous one.

In the following example we are resuming the download of the Ubuntu 18.04 iso file:

wget -c

If the remote server does not support resuming downloads, Wget will start the download from the beginning and overwrite the existing file.

How to download in background

To download in the background use the -b flag. This is useful when you are downloading large files. In the following example we are downloading the OpenSuse iso file in the background:

wget -b

By default the output is redirected to wget-log file in the current directory. To check the status of the download you can use tail -f wget-log.

How to change the User-Agent

Somethimes when downloading a file the remote server may be set to block the Wget User-Agent. In situations like this to emulate a different browser pass the -U flag.

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

The command above will emulate Firefox 60 requesting the page from

How to Download Multiple files

If you want to download multiple files at once use the -i flag followed by the path to a local or external file containing a list of the URLs to be downloaded. Each URL needs to be on a separate line.

In the following example we are downloading the Arch Linux, Debian and Fedora iso files with URLs specified in the linux-distros.txt file:

wget -i linux-distros.txt

If you specify - as a filename, URLs will be read from the standard input.

How to download via FTP

To download a file from a password protected FTP server you need to specify the username and password as show bellow:

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

How to create a mirror of a website

To create a mirror of a website with Wget you would use the -m flag. This will create a complete local copy of the website by following and downloading all internal links as well as the website resources (Javascripts, CSS, Images).

wget -m

If you want to use the downloaded website for local browsing, you will need to pass few extra arguments to the command above.

wget -m -k -p

The -k flag will cause Wget to convert the links in the downloaded documents to make them suitable for local viewing and the -p flag will tell wget to download all necessary files for displaying the HTML page.

How to skip certificate check

If you want to download a file over HTTPS from a host that has an invalid SSL certificate use the --no-check-certificate flag:

wget --no-check-certificate

How to download to standard output

In the following example Wget will quietly ( flag -q) download and output the latest WordPress version to stdout ( flag -O -) and pipe it to the tar utility which will extract the archive to the /var/www directory.

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


By now you should have a good understanding of the most common Wget options, and you should be able to use Wget to download multiple files, resume partial downloads, mirror websites and combine the Wget options according to your needs.

If you want to learn more about Wget visit the GNU wget Manual page.