Most Linux users prefer to carry out their periodic file download requirements from a command-line interface. It is a convenient approach as they do not have to switch between web browsers’ GUI tabs or go through several redirecting download buttons before initiating the actual download of the files they need. This objective is achieved by using a terminal-based file download program.
Wget is one such program. To use it, you only need to prefix the URL containing the file you wish to download with the command wget.
[ You might also like: How to Force Wget to Use IPv4 or IPv6 Connection ]
Consider the following wget syntax:
$ wget [options] [URL_to_targeted_file]
A simple example would be the download of a free photo from the Unsplash website.
$ wget https://unsplash.com/photos/GnxkfkFHGOM/download?force=true
Wget and Proxy
When a proxy server is in the picture, using wget to download a file is no longer as straightforward as demonstrated above. It is because a proxy server acts as a bridge between the remote computer or server (holding the file you wish to download) and your client or local machine (anticipating the file download to start and end successfully).
Since a proxy server offers a firewall-and-filter functionality, some authentication is required before we can be able to successfully download any file.
Download File with Wget Using Proxies IP Addresses and Port
Since wget supports the use of common protocols like HTTP, HTTPS, and FTP, we can set proxies related to these protocols as per the following syntax:
export ftp_proxy=FTP_PROXY:PORT export http_proxy=HTTP_PROXY:PORT export https_proxy=HTTPS_PROXY:PORT
In the above syntax:
- FTP_PROXY points to the associated FTP proxy server address.
- HTTP_PROXY points to the associated HTTP proxy server address.
- HTTPS_PROXY points to the associated HTTPS proxy server address.
- PORT points to the address port associated with each proxy server address.
Based on the above syntax, a wget via proxy file download scenario under HTTP and HTTPS protocols will follow the following command sequence.
$ export http_proxy="PROXY_IP:PROXY_PORT" $ export https_proxy ="PROXY_IP:PROXY_PORT" $ wget URL_to_Downloadable_File
Download File with Wget Using User Authentication
In this case, instead of setting your proxies with the needed user authentication credentials, you can pass them through the succeeding wget command.
Consider the following full implementation of wget proxy file download via HTTPS protocol.
$ export https_proxy="https://PROXY_SERVER_ADDRESS:SERVER_PORT" $ wget --http-user= "YOUR_USERNAME" --http-password= "YOUR_PASSWORD" https:// PATH_TO_DOWNLOADABLE_FILE
The wget terminal-based file download tool is an interestingly flexible application to master for your Linux file download needs whether you are retrieving remote files via proxies or not. Its command usage has more to offer than what this article guide has covered.
To know more about the depth of wget usage, key in the following commands on your Linux terminal environment.
$ man wget $ wget --help