Wget follows the links in the HTML and CSS pages and works recursively. Which makes it smart for cloning remote websites and running them on local machines. This is sometimes referred to as “recursive downloading.”

How to Install Wget on Linux

Generally, the Wget package is pre-installed on Linux distributions. But in some cases of minimal installations, It may not be installed. Open a terminal and execute the following commands to install or upgrade the Wget package from the default package manager.

On Ubuntu, Debian & Linux Mint Systemssudo apt update && apt install wget -y On CentOS, RHEL & Fedora Systemssudo dnf install wget -y

Wget Command Syntax

A simple Wget command follows the below syntax. A large number of command-line options make it more usable. Wget uses GNU getopt to process command-line arguments, which means all options have a long-form along with a short one. Wget required a URL to an archive, IOS, or webpage to download.

Wget Command Examples

Here are some frequently used wget commands with examples.

1. Downloading a file using Wget

Open a terminal and type wget followed by the remote file URL to download on the local machine. No additional parameters are required to download a file. The above command will download the file in the current working directory. The filename will remain the same in the local system as on the remote machine.

2. Downlaod file with a New Name

Default wget downloads the file with the same name on the local system. Use -O (Capital O) command-line option followed by a new name to write file on local system. See the below screenshot, showing the local file is created with a new name.

3. Downlaod Large files with Resume Option

The Wget allows us to resume downloading for a partially downloaded file. It is helpful for downloading large files from a remote. In any case, the download interrupts, can resume downloading remaining content only instead of full download. Use -c or –continue switch with the file. See the below example, Downloading a large file with -c option. In the first attempt, once the downloading started killed the download process with CTRL+C. Now again execute the same command and you can see the downloading resumes.

4. Wget to Execute Remote Scripts without Creating Local File

Wget is also widely used for executing remote scripts through scheduled jobs like crontab. But we found that it creates a new file with each run under the home directory. We can instruct wget to redirect all content to /dev/null and ignore creating files. Here -q will suppress all the output on-screen and -O will redirect all the content to /dev/null file.

5. How to Mirror a Website in Wget

Wget allows us to download website content recursively. It follows the internal links available in HTML content. Use –recursive option with wget command to download entire site in your local system. You can also set the maximum depth for recursion with -l opiton. The above commands will create a directory with the same name to the domain in the current directory and place all files under it.

6. How to Authorize Requests with User & Password

Most of the files over remote FTP servers are secured with authentication. In some cases, content over the HTTP can be secured with authentication. Wget allows us to pass authentication details with this request. You can use –user and –password for both FTP and HTTP authentications.


In this tutorial, you have learned the basics of the Linux wget command with examples.

Wget Command in Linux with Examples   TecAdmin - 59Wget Command in Linux with Examples   TecAdmin - 52Wget Command in Linux with Examples   TecAdmin - 76