If you are a user of Ubuntu, Debian, CentOS, or any other popular distribution of Linux, you might already know about the mighty wget, which is a powerful command-line download manager. Using wget, you can download files from the internet, using multiple protocols like HTTP, HTTPS, FTP, and many more. Downloading with wget is pretty simple, as well. Simply append the download link at the end of the wget command and hit the enter key to start downloading the file in the present working directory. However, there is a way, you can download the same to a preferred directory.
As wget is a powerful tool, it can also be used to download files exactly the way you want, with numerous additional prefixes and arguments so that you can get the most out of wget. Even though wget is a command-line download manager, and it doesn’t have any user interface or GUI, that doesn’t mean, you can’t get the elite features, which a powerful graphical download manager has to offer. You just have to know the appropriate ways to add additional arguments and get the most out of it. Knowing the bonus features of it can undoubtedly help you to deal with broken downloads and all other mishaps that might happen while you proceed with downloading files from the internet.
So, without any further delay, let’s get started with the additional arguments and prefixes that you can use with wget. Find about it more here.
The commands are given here work for all Linux distros- Ubuntu, CentOS etc. To install it:
sudo apt get install wget or sudo yum install wget
Wget command to download files in a specific directory:
wget <download URL> -P <local direcory> / wget <download URL> --directory-prefix <local direcory>
wget http://ubuntu-releases.mirrors.estointernet.in/18.04.3/ ubuntu-18.04.3-desktop-amd64.iso -P /Download
This will download the file to the directory Download in the specified location, or any other directory, as specified, no matter, what the current working directory is.
Getting download messages to a log:
wget <download URL> -o <log_filename> / wget <download URL> --output-file <log_filename>
wget http://ubuntu-releases.mirrors.estointernet.in/18.04.3/ ubuntu-18.04.3-desktop-amd64.iso -o ~/Downloads/log.txt
With the help of this, no download message will be displayed on the command line but will be written as a log to the specified log file, including the errors, if any occur. If the file doesn’t exist, a new file will be created for the log.
Appending to the log:
wget <download URL> -a <log_filename> / wget <download URL> --append-output <log_filename>
wget http://ubuntu-releases.mirrors.estointernet.in/18.04.3/ubuntu-18.04.3-desktop-amd64.iso -a ~/Downloads/log.txt
This works the same way as the last command, but with the ‘append-output’ argument, the new messages will be appended to the end of the specified file. If the file doesn’t exist, a new file will be created with the name.
Enabling the quiet mode / non-verbose mode:
wget <download URL> -q / wget <download URL> --quiet
wget http://ubuntu-releases.mirrors.estointernet.in/18.04.3/ ubuntu-18.04.3-desktop-amd64.iso -q
This will enable quiet mode. Neither any outputs will be displayed onscreen, nor will it be saved to any location as a log file. If there are errors, that will not be displayed, as well. Unless you are sure about the existence of the file in the remote server, I will recommend you to not proceed with this argument.
However, to get important messages and errors, and ignore other messages, simply use the ‘-nv’ or ‘–non-verbose’ flag, as shown below.
wget http://ubuntu-releases.mirrors.estointernet.in/18.04.3/ ubuntu-18.04.3-desktop-amd64.iso -nv
Downloading from a file / multiple files download back-to-back:
wget -i <input_file_path> / wget -i <input_file_path>
wget -i ~/Documents/Links.txt
If you have to do multiple downloads at once, the link to each file should be saved in a file, which is the file ‘Links.txt’ in this case. Only one link should be present in a line. After entering a link, you have to hit the enter key to move to the next line to enter a new link. This is similar to downloading files using magnet links, where the link is present in a file.
If there is a general link with wget, and there is an input file, the download of links in the input file will be followed by the download of the link specified by you with the wget command.
Continuing with a broken download:
wget -c <download_URL> / wget --continue <download_URL>
wget -c http://ubuntu-releases.mirrors.estointernet.in/ 18.04.3/ubuntu-18.04.3-desktop-amd64.iso
There are times when you need to carry on with a download after it has failed due to a power outage, connection drops, and other troubles. If there is already an existing file with the name ‘ubuntu-18.04.3-desktop-amd64.iso’, which is incomplete, wget will try downloading the remaining part of the file. However, if the remote server doesn’t support resuming of downloaded files, there is no other option other than downloading the file from the beginning.
Download password protected files:
wget <download_URL> --user=<user_name> --password=<password>
For FTP connections:
wget <download_URL> --ftp-user=<user_name> --ftp-password=<password>
At times, we often come across websites, where a username and password is required to download files, and there’ s when you can use this extra argument to download the files, which is protected by a username and password.
Limiting bandwidth for downloads:
wget <download_URL> --limit-rate=<bytes>
wget http://ubuntu-releases.mirrors.estointernet.in/ 18.04.3/ubuntu-18.04.3-desktop-amd64.iso --limit-rate=20k
This will limit the download speed to 20 kilobytes per second. Besides, kilobytes, the speed limit can also be defined in megabytes, gigabytes, and terabytes.
These suffixes are not case-sensitive. If you have limited bandwidth or simply don’t want wget to use all the available bandwidth to download files, limiting the download speed can be useful to use your internet connection and its available bandwidth, more effectively.
So, those were the most useful wget arguments that most people will need. All the arguments I have mentioned here are available as neat features on popular download managers available for Windows and other popular platforms. So if you have switched to Linux, or is looking for a GUI-based download manager for some bonus features and convenience, you might now keep using wget and enjoy the most useful benefits of a proper download manager.
There are a number of other arguments you can use wget, but that will hardly be useful for every user, and thus, I have kept them away from this list.
So that was my list of top 8 arguments to use with wget and get the maximum convenience of downloading files on Linux. Do you know any other useful arguments for wget? Feel free to comment on the same below.
Other Useful Articles:
>> Source Link