How to use Wget to download files on Linux
GNU/Linux has many practical uses. You can easily process all your transactions through Terminal. If you have read or watched Linux related video tutorials, 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, 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
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.
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
After this step, you can view 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 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
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
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
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.
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.
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.
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.
You should read it
- How to install and use wget on Mac
- The difference between cURL and wget
- How to convert multiple websites into PDFs with Wget
- How to 'Resume download' when downloading files is interrupted in Google Chrome
- How to download the entire website for offline reading
- How to check Internet speed with the Command Line
- How to download files faster with Persepolis
- How to download Torrent file by IDM?
- How to set up Coc Coc default download torrent
- How to use Steam to download files from the Internet
- How to skip file loading time with 3 utilities on Chrome
- How to download Torrent on Android uses BitTorrent
Maybe you are interested
15 safe software and application download websites for Windows
More than 200 apps containing malicious code were discovered and downloaded millions of times on the Google Play Store.
How to download Google Photos to your computer, export Google Photos library
How to download TikTok videos without watermark on computer using x2convert
How to use Motrix Download Manager to download Windows files
23 Free Ways to Download Any Video from the Internet