Where is this environment variable set?
Whenever I open a terminal I have this variable set:
$ echo $http_proxy
http://127.0.0.1:8888/
Where is this variable being set? I've checked .bashrc
, .bash_profile
, /etc/bash.bashrc
and /etc/environment
and it's nowhere there?!
I've also looked at System Settings in the network section and the proxy is empty.
For bash
run:
PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7> /tmp/mylog
then use
grep "http_proxy=" /tmp/mylog
to search for it.
You can also limit the search to /home
and /etc
for a better result:
$ grep "http_proxy=" /tmp/mylog | grep -e /home -e /etc
++/home/ravexina/.bashrc> http_proxy=http://test:80
which means it has been set in my ~/.bashrc
.
source
According to essentially the duplicate of what you asked on Unix & Linux site, there are couple of ways to approach this problem:
- use
env
command and observe the order in which variables were created, and use preceding and next variables to get rough idea of where the variable may have come from - wrap files which you try to investigate with
set -x
command in the beginning and end of the file to see what each file does; potentially those files are sourcing other files, andset -x
should explicitly state where sourcing occurs - Consider going through some of the files you may have in your home folder via
find -type f -exec grep 'VARIABLE_NAME' {} \;
or justgrep -rI 'VARIABLE'
. This is time consuming , so might not be the best result, but hey - if there's no easy methods, one shouldn't put aside the hard ones. - Run
strace -v -s 10000 -e execve,open,read bash
and observer what is being read and what is the precedingopen()
call. This might be useful with2&>1 > output_trace.txt
redirection to read later and maybegrep
. Source -
You mentioned .bashrc, .bash_profile, /etc/bash.bashrc and /etc/environment. You also need to check:
/etc/profile
/etc/profile.d/*
-
~/.profile
(only if you don't have a~/.bash_profile
) ~/.bash_login
According to Arch Wiki, some programs like
wget
use this variable. Check if you might have.wgetrc
or/etc/wgetrc
file. This might be set there, although where it gets sourced intobash
is another mystery