Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Use Wget to Download Files on Linux

Learn about Wget, including Quick Start Guide, key uses, practical steps, common issues, and answers to frequently asked questions.

Table of Contents

This practical guide explains how to use wget to download files on linux with clear steps and useful context. It also covers common requirements, potential problems, and the details that can help you get better results.

For example, if you know the direct download link of the file you want to download, you can download it from the console with the help of the wget command without using any additional programs or a browser.

Here's everything you need to know about the wget command including some practical examples.

Quick Start Guide

  • To download a single file, find the file link > apply the wget link_download command.
  • To download multiple files, save the links you want to download in a file, and then use the -i parameter with the wget command.
  • To download a file to a custom location, create the directory where you want to save the file, then use the -P flag with the wget command and specify the full path to the desired location.
  • To specify a custom filename, create a new directory, load the file with the custom name with the wget -O parameter.
  • To resume interrupted downloads with Wget, use wget -c link_download.
  • Limit Wget's download speed with wget --limit-rate link_download speed.
  • To download files in the background, use the -b parameter.

Detailed Instructions

Download a Single File

This is one of the most basic uses of the wget command. The intent here is to download a single file into the system using a known destination link. The wget command used for this is:

wget https://download.aircrack-ng.org/aircrack-ng-1.7.tar.gz

Download a Single File - Wget

As shown in the image, you can download the file with the wget command and find where to download it with ls -l.

Batch Download of Files

Multiple files from links stored in a text document can be downloaded at once using the -i parameter with the wget command.

For example, you want to download all PDF files at a certain address at once. To do this, you need to save the download links of these PDF files in a text document. You can do this by creating a file named my_pdfs with the vim my_pdfs command and adding the necessary links to the file.

Batch Download of Files - Wget

Let's download the PDF formats of Google Cloud documents as an example. Save links to PDF files in a file and use the following command to download them:

wget -i my_pdfs

Batch Download of Files - Wget

After this step, you can view the downloaded files by running:

ls -l

Batch Download of Files - Wget

Download by Specifying a Custom Location

If you want the file to download to a special location on your system, you need to use the -P flag with the command:

wget -P /path/to/dir filelink

You can see this in the example below. Likewise, try downloading the file aircrack-ng and this time specifying an address. For example, you can create a folder Myfile to store downloaded files.

wget -P Myfile https://download.aircrack-ng.org/aircrack-ng-1.7.tar.gz

Download by Specifying a Custom Location - Wget

To download the file to the desired location, you must specify the full path to the directory. You can also run the following ls -l command to make sure the file is actually where you want it to be.

Download by Specifying a Custom Filename

With the wget -O parameter, you can name the file you want to download and download it to any location you want. To avoid confusion, create a new oParameter folder and try to download your aircrack-ng file to this folder by giving it the name you want, in this case aircrack.

wget -O oParameter/aircrack https://download.aircrack-ng.org/aircrack-ng-1.7.tar.gz

Download by Specifying a Custom Filename - Wget

After Wget has finished downloading the file named "aircrack" and saving it to the /oParameter directory, you can confirm this with the command ls -l.

Also, if you want to change the name of the downloaded file without changing its location, just specify the new filename without specifying any location. For example, you can change the name of the file to download using the wget new_name file_link command. Since you don't specify any location, it will automatically download at your current working directory.

wget myfilename https://download.aircrack-ng.org/aircrack-ng-1.7.tar.gz

Download by Specifying a Custom Filename - Wget

Resume Interrupted Downloads with Wget

Failed download is one of the most common problems when downloading large files. In such cases, you can continue the download and get the rest of the file.

You can use the -c parameter with the wget command to re-download the interrupted file. Therefore, by using wget -c download_link, if the file is not completely downloaded, you have the opportunity to continue from where it left off instead of re-downloading it from the beginning. This is very practical, especially for large files.

To better understand this, first create a folder called Resume on the desktop. Access this folder using Terminal with the cd command and try to download the aircrack file you used in the other examples here. Then, interrupt this download with the keyboard combination Ctrl + Z.

Resume Interrupted Downloads with Wget - Wget

As you can see, 19% of the files have been downloaded, occupying 1645946 bytes. Now use the -c parameter in the same way and try to resume the download.

Resume Interrupted Downloads with Wget - Wget

As you can see, the download is complete. Thus, there is no need to delete the file and re-download it from the beginning. This is just a small file for example. But for very large files, you can save time by using Wget.

Wget Download Speed Limit

If you want, you can limit the download speed for the file. To set this limit, you can use the following command:

wget --limit-rate 300K https://download.aircrack-ng.org/aircrack-ng-1.7.tar.gz

This command will limit the download speed to 300KB per second.

Wget Download Speed Limit - Wget

You can try different speeds by varying the value of 300K.

Download Files in the Background

You can download files in the background with the -b parameter. This is most useful when you are busy with many tasks. Also, if you want to find out the result of the download, you can simply check the wget-log file located in the same location as the downloaded file.

Download Files in the Background - Wget

Conclusion

Understanding Wget makes it easier to compare options, avoid common mistakes, and apply the information in this guide more effectively. Review the relevant requirements before making changes or choosing a solution.

FAQ

How do you use wget to download files on linux?

Follow the steps in this guide in order, confirm the required settings or tools, and verify the result before making additional changes.

Is it safe to use wget to download files on linux?

It is generally safe when you follow the recommended instructions, use trusted tools, and avoid changing settings you do not understand.

What should you do if the process does not work?

Recheck the requirements, restart the device or application when appropriate, and review each step for missed settings or compatibility issues.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.