If zsh
is your login shell:
zsh -xl
With bash
:
PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7>&2
That will simulate a login shell and show everything that is done (except in areas where stderr is redirected with zsh
) along with the name of the file currently being interpreted.
So all you need to do is look for the name of your environment variable in that output. (you can use the script
command to help you store the whole shell session output, or for the bash
approach, use 7> file.log
instead of 7>&2
to store the xtrace
output to file.log
instead of on the terminal).
If your variable is not in there, then probably the shell inherited it on startup, so it was set before like in PAM configuration, in ~/.ssh/environment
, or things read upon your X11 session startup (~/.xinitrc
, ~/.xsession
) or set upon the service definition that started your login manager or even earlier in some boot script. Then a find /etc -type f -exec grep -Fw THE_VAR {} +
may help.
/etc/environment
is another one. – derobert Aug 20 '10 at 18:44/etc/env.d/*
files. But doinggrep -R "YOUR_VARIABLE" /etc/
is probably the best way to find out. – rozcietrzewiacz Aug 28 '11 at 00:53