Where a bash variable (proxy) is defined

1

I have a problem with wget and I've discover that my proxy settings is wrong:

$ env | grep "proxy"
http_proxy=http://213.181.73.145:80
https_proxy=http://213.181.73.145:80

So, when I try to download something with wget, it fails trying to connect to the proxy, and not trying to connect to the web resource that I need to download.

But in superuser mode all is correct:

$ sudo su
$ env | grep "proxy"
$

(empty output, no proxy)

I want to know where this variables are settings, and I found a lots of problems. I added the next line to the beginning of my /etc/profile:

env | grep "proxy"
echo "Hello"

And for me surprise, both variables are settings with that same values before any configuration file is loaded (/etc/bashrc, ~/.bashrc, etc):

(new terminal)
http_proxy=http://213.181.73.145:80
https_proxy=http://213.181.73.145:80
Hello
$

Moreover, I work with guake. So, I tried the same with a common terminal, and for me surprise, (I think) the file /etc/profile isn't loaded, since I don't see nor the proxy lines but neither the echo "Hello" message.

So, I would like to know how is possible that http_proxy and https_proxy are defined before loading /etc/profile and why I don't see the "Hello" message when I open a common terminal.

Peregring-lk

Posted 2013-04-14T17:43:18.363

Reputation: 215

Answers

0

The message is not displayed when you open a "normal" terminal because /etc/profile is only read for login shells, a "normal" terminal starts an interactive, non-login shell. See my answer here for more information.

Now, I don't know where your http_proxy is set. Depending on what exactly your setup is, it could be in various places. Try this:

grep http_proxy /etc/bash.bashrc /etc/profile ~/.bashrc ~/.bash_login ~/.profile ~/bash_profile

The variable should be set in one of those files.

terdon

Posted 2013-04-14T17:43:18.363

Reputation: 45 216

0

Some file that is run on shell startup is setting the environment variables, such as ~/.bashrc , ~/.bash_profile, or /etc/bash.bashrc

You don't have to change any file to take off the proxy variable, though! All you have to do is use the 'unset' command!

$ unset http_proxy
$ unset https_proxy

Now those environment variables are gone! If you can't track down where they are set, you can add that to the end of your ~/.bashrc, and unset them for every shell. If you test it out again:

$ env | grep proxy
[nothing]

You'll see they've gone!

KebertX

Posted 2013-04-14T17:43:18.363

Reputation: 11

But, the key of the question is that this variable is set before any configuration file is loaded. The question is where can a variable be setted before /etc/profile. – Peregring-lk – 2013-04-15T07:21:31.697