How to use the Linux wget command to download files from the internet

By using the Linux command wget you can start the program of the same name and download files from the internet. This command gives you plenty of options to optimize the process as well.

What is the Linux wget command?

wget is an important tool on Linux systems if you want to download files from the internet. The program allows you to download content directly from your terminal. First released in 1996 and managed by the GNU project wget is a free tool that comes as standard on most Linux distributions such as Debian or Ubuntu. You can initiate downloads by using the wget command. Downloads are supported by FTP-, HTTP and HTTPS servers.

If you don’t have wget on your Linux system, you can install it by using the following command:

$ sudo apt-get install wget
shell

How does the wget command work?

You can use the wget command to download a file from the internet. Files are automatically saved in your current work folder. The download won’t take place interactively. This means that processes can be carried out even when you’re not logged in. This option is also used to restart a download that was previously stopped.

What does the wget syntax look like?

Once you’ve installed Linux wget, you can use the command to download content. This is what the syntax looks like:

$ wget [Option] [URL]
shell

You can also modify wget through different options. If you want to download multiple files you can list the corresponding URLs and simply separate them with a space.

What options does the wget command have?

There are numerous options for wget. These are the most common:

  • -c or –continue: Continues a previously interrupted download.
  • -N: Will only download a file if it’s newer than a file of the same name on your computer.
  • -t [amount]: Sets how many times Linux wget will try to download a file.
  • -w [time]: Sets how many seconds wget will wait between multiple downloads.

Examples of a wget command

Finally we will show you how you can use wget. Here are a few examples:

$ wget http://example.ca/folder/file
shell

This is how you can download a file.

$ wget -c http://example.ca/folder/file
shell

And with this command you can restart a download.

$ wget -t 5 http://example.ca/folder/file
shell

In this example wget will attempt to download the file five times. If these five attempts aren’t successful, the download will fail.

We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.