Linux

How to Use Wget to Download Files on Linux

GNU/Linux has many practical uses. You can easily handle all your transactions via the terminal. If you’ve read Linux-related instructions or watched videos, you must have come across the wget command. It is very easy to use and works by taking parameters.

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

MAKEUSEOF VIDEO OF THE DAY

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

Downloading a Single File

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

wget https:

As it is evident in the image, you can download a file with the wget command and find where it is downloaded with ls -l.

Batch Downloading Files

It is possible to download multiple files from links saved in a text document all at once by using the -i parameter with the wget command.


For example, you want to download all the PDFs at a certain address at the same time. For this, you need to save the download links of these PDFs 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 it.

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

wget -i my_pdfs

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

ls -l

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 to download an aircrack-ng file and this time specify an address. For example, you can create a Myfile directory to store the downloaded file.

wget -P Myfile https:

To download your file to the desired location, you must specify the full path to the directory. You can also run the ls -l command later to make sure your 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 directory by giving it the name you want, in this case, aircrack.

wget -O oParameter/aircrack https:

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

In addition, if you want to change the name of the downloaded file without changing its location, it is sufficient to specify the new file name without specifying any location. For example, you can change the name of the file to download by using the wget new_name file_link command. Since you do not specify any location, it will automatically land at your present working directory.

wget myfilename https:

Resume Interrupted Downloads With Wget

Failed downloads are one of the most common problems while downloading large files. In such cases, it is possible to resume the download and get the rest of the file.

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

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

As you can see, 19 percent of the file was downloaded, which accounts for 1645946 bytes. Now use the -c parameter in the same way and try to continue the download.

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

Limiting Wget Download Speed

If you want, you can cap your download speed for the file you are going to download. For this limitation, you can use the following command:

wget --limit-rate 300K https:

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

You can try different speeds by changing the 300K value.

Downloading Files in the Background

You can download a file in the background with the -b parameter. This is useful most of the time when you are busy with other work in the foreground. In addition, if you want to learn the results of the download process, it will be sufficient to examine the wget-log file located in the same location as the downloaded file.

File Downloads Made Easy With Linux and Wget

Since GNU/Linux is a completely open-source system, it provides an infrastructure that you can customize however you want. You can take advantage of hundreds of thousands of applications and libraries made for Linux. You can handle everything with Wget without the need for any programming knowledge or downloading a program. It is very easy to control the download processes of files that you will download and install on your system with the wget command.

Also, remember that many sources of software other than official websites can endanger your security. That’s why you should always be skeptical of the download links that you use with Wget.

Source link

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button