wget
is a command line tool created by the GNU Proyect and is used for downloading via HTTP, HTTPS, and FTP. In this article, we will look at some useful commands that can be used with wget
to download files from the web.
Downloading a File
To download a file with wget
, simply specify the URL of the file you want to download:
$ wget https://www.gnu.org/licenses/gpl-3.0.txt
The file will be downloaded to your current directory and keep its name.
Specify a File Name
If you want to change the name of the file to download, add the -O
parameter, followed by the name you want to assign:
$ wget -O GNULicense https://www.gnu.org/licenses/gpl-3.0.txt
Download a File to Specific Directory
To specify a directory where the file is going to be downloaded, use the -P
parameter:
$ wget -P ~/Documents/ https://www.gnu.org/licenses/gpl-3.0.txt
Show Progress Bar of a Download
To show the progress bar of your download, add the --show-progress
parameter:
$ wget --show-progress https://www.gnu.org/licenses/gpl-3.0.txt
Set a Speed Cap For the Download
To download a file at a very specific download speed, you can add the --limite-rate
parameter and specify the speed in kilobytes with k
:
$ wget --limit-rate 35k https://www.gnu.org/licenses/gpl-3.0.txt
In the command above, we set to download the file at a 35 KB/s download speed.
Resume an Interrupted Download
To resume a failed or interrupted download, add the -c
parameter:
$ wget -c https://www.gnu.org/licenses/gpl-3.0.txt
Retry a Failed Download
To retry a failed download you can use the -t
parameter, followed by the number of retries you want to attempt. You can also use -t inf
option, if you want your retries to be infinite:
$ wget -t 30 https://www.gnu.org/licenses/gpl-3.0.txt $ wget -t inf https://www.gnu.org/licenses/gpl-3.0.txt
Download a File in the Background
If you want to download a file in the background, simply add the -b
parameter:
$ wget -b https://www.gnu.org/licenses/gpl-3.0.txt
Download Multiple Files
To download multiple files, you have to add the links to a text document first (one per line). Once it is saved, you can proceed to download them with the next command:
$ wget -i filename.txt