How to Download Files Via Terminal Using Wget
Wget is a tools based on command line interface which serves to download, whether in the form of a file, a folder or a website page. Wget has been around for a long time and is still being used today, being one of the best download managers.
Although based on command line interfacewget has many features that are not inferior powerful compared with download manager modern GUI based. In this terminal tutorial, we will learn how to use wget to download.
To use wget, make sure you have wget on your system. Usually wget is readily available default on Linux distributions.
How to Download a Single File Using Wget
As usual, as a starter we will learn the easiest and most basic way, which is how to download a single file.
To download a single file, it’s very easy, you just need to type the wget command and follow it with link of the file you want to download.
For example, you want to download the Ubuntu “.iso” file from the official Ubuntu website. Go to the website https://www.ubuntu.com, and copy link of the file you want to download.
Then enter the wget command in Terminal followed by the link of the file you want to download that was copied earlier, as follows:
wget http://ubuntu.biz.net.id/18.04/ubuntu-18.04-desktop-amd64.iso
Then wget will download the file as shown below:
Wait for the download process to complete. The downloaded file from the file will be in the Home folder or depending on the directory you were in when you downloaded it.
How to Resume Stopped File Downloads Using Wget
Wget has the ability to resume downloads of files that have been stopped. You can continue the download process by using the same link and adding parameter “-c”.
For example, when you download the Ubuntu “.iso” file as in the example above, then the download process stops for some reason. You can resume the download process by using a command like the following:
wget -c http://ubuntu.biz.net.id/18.04/ubuntu-18.04-desktop-amd64.iso
Then wget will continue the download process from several parts of the file that have been downloaded previously, so you don’t have to start the download process from scratch again.
How to Download Entire Website Pages Using Wget
Wget can also be used to download entire web pages. To do this, for example, you want to download the W3schools.com website, you can do this by using the following command:
wget -m https://www.w3schools.com
Then wget will do mirroring all files from the website as in the image below:
by default command like above will download all files from the site as a whole. If you want to download a website page with more advanced options, you can use several options parameter different as in the following example:
wget --convert-links -m https://www.w3schools.com
The command as above serves to change the links in each downloaded page so that they can connect to each other, not link or point to the original page.
wget --page-requisites -m https://www.w3schools.com
This parameter is used to download files styling like CSS too, so the downloaded page will have the same and beautiful appearance even if it’s in a state offline or not connected to the internet.
wget --no-parent -m https://www.w3schools.com/html
This parameter works so that wget doesn’t download files from its parent site, for example you only want to download the HTML tutorial section page from the w3schools.com web, so you only download the https://www.w3schools.com/html page, not from the whole site.
You can also combine these parameters to download web pages the way you want.
How to Download All Files in One Directory or One Folder
If you’re downloading from an FTP server and find a folder or directory that you want to download all of its contents from, in this example it’s the folder from the Debian FTP server that contains the Debian iso files and others — you can download them using the parameters “-r” as follows:
wget -r https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/
Then wget will download all the contents of the file from the folder as shown below. Parameter “-r” the command serves to perform recursive downloads so that wget will download the entire contents of a folder.
Just like in the download section of the previous website page, you can also add parameters “–no-parent” if you don’t want to download files and folders that are under the current directory.
How to Download Multiple Files in One Download Using Wget
If you want to download many files in one download, but the files are not in the same folder or directory as in the example above, you can download these files in one download by collecting the link of each file. want to be downloaded into a file that has the format “txt”.
Enter the links of the file you want to download into a file as shown below, then save it with the name “filedownload.txt” or whatever and put it in the “Home” folder.
Then do the download using parameter “-i” as follows:
wget -i filedownload.txt
Then wget will download all files whose links are in the file as shown below, wait for the download process to complete.