The following article will teach you how to allow your Linux system to use a proxy server for command line tools like wget and yum.
The http_proxy variable tells the system what proxy server it should used to fetch URLs on the command line. This allows you to manually download a file via http, https and ftp and also allows most other command line programs to get files from the internet (for example the yum command to update you Linux system).
To set the http_proxy variable just have to assign a value to it like so:
You must give the value in the URL:PORT format like above. Now if you request a resource from the internet on the command line it will work fine. A simple test would be to fetch our homepage.
$ wget http://putorius.net
After running the above command you should have an index.html file which is our homepage you just downloaded.
If you set the variable like mentioned above it will only work for the current shell. If you close the terminal, log out, or create a new shell (terminal window) the variable will not work. For it to work on all new shells you must export it, or what is known and make it a global variable, like so:
or on one line:
http_proxy=http://myproxy.domain.com:8080; export http_proxy
This will still only be useful for all child shells. To make this setting survive a reboot you can put the command in your .bashrc file. This will actually set the variable and export it every time you open a shell.
echo "http_proxy=http://myproxy.domain.com:8080" >> ~/.bashrc
Or you can manually edit the ~/.bashrc file and add the line about with your favorite text editor.
Once you update the bashrc file, you need to source it to load the new file.
Setting it in the ~/.bashrc file is only going to work for the one user who’s home directory the .bashrc file resides in. To make this a global variable for all users place it in the /etc/bashrc file.
echo "http_proxy=http://myproxy.domain.com:8080; export http_proxy" >> /etc/bashrc
This site uses Akismet to reduce spam. Learn how your comment data is processed.