How to set a proxy for wget on Linux?

LinuxOperating SystemOpen Source

Wget is a Linux command line utility that is used to retrieve files from World Wide Web(WWW) and makes use of protocols like HTTPS and FTP. It is a freely available package and can be downloaded and installed on any Linux supporting architecture.

One of the key features of wget is its ability to automatically start downloading where it was left off in case there is a network issue. It should also be noted that it deletes files recursively and it will keep trying to download all the files until it has been retrieved completely.

Installing wget

For Ubuntu/Fedora

sudo apt-get install wget

For Mac OS X

yum install wget

Now we know about wget, let’s first explore an example where we will try to download a file from a url with the help of the wget command.

Example

wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz

Output

immukul@192 linux-code % wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
--2021-07-11 12:12:20-- http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
Resolving ftp.gnu.org (ftp.gnu.org)... 209.51.188.20
Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446966 (436K) [application/x-gzip]
Saving to: 'wget-1.5.3.tar.gz'

wget-1.5.3.tar.gz
100%[========================================================>]
436.49K 285KB/s in 1.5s

2021-07-11 12:12:23 (285 KB/s) - 'wget-1.5.3.tar.gz' saved [446966/446966]

Now, if we want to use a proxy with the wget command, we can make use of either of the two approaches mentioned below.

Approach 1

Command

wget -e use_proxy=yes -e http_proxy=localhost:8080 ...

Approach 2

Command

use_proxy=yes

http_proxy=localhost:8080

https_proxy=localhost:8080

Both the above approaches will enable you to run the wget with a proxy on.

raja
Published on 30-Jul-2021 09:16:55
Advertisements