What ever set's the environment variable last wins. So it doesn't really matter, I would just set the variable in the oracle user's $HOME/.bashrc
file towards the bottom.
The file $HOME/.bashrc
is the key file which sources files such as /etc/bashrc
and the files under /etc/profile.d/*.sh
for example. So I would just set ORACLE_SID=whatever
in $HOME/.bashrc
.
Debugging Tip
If you want to see what's going on you can debug your login like so:
su - oracle -c "env SHELLOPTS=xtrace bash"
With the above command you can follow along as the different files are sourced by bash:
...
...
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/less.sh ']'
++ '[' '[\u@\h \W]\$ ' ']'
++ . /etc/profile.d/less.sh
+++ '[' -x /usr/bin/lesspipe.sh ']'
+++ export 'LESSOPEN=||/usr/bin/lesspipe.sh %s'
+++ LESSOPEN='||/usr/bin/lesspipe.sh %s'
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/PackageKit.sh ']'
++ '[' '[\u@\h \W]\$ ' ']'
++ . /etc/profile.d/PackageKit.sh
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/qt.sh ']'
++ '[' '[\u@\h \W]\$ ' ']'
++ . /etc/profile.d/qt.sh
+++ '[' -z /usr/lib64/qt-3.3 ']'
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/udisks-bash-completion.sh ']'
++ '[' '[\u@\h \W]\$ ' ']'
++ . /etc/profile.d/udisks-bash-completion.sh
+++ '[' -z '4.1.7(1)-release' ']'
+++ complete -o filenames -F __udisks udisks
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/vim.sh ']'
++ '[' '[\u@\h \W]\$ ' ']'
++ . /etc/profile.d/vim.sh
+++ '[' -n '4.1.7(1)-release' -o -n '' -o -n '' ']'
+++ '[' -x //usr/bin/id ']'
++++ //usr/bin/id -u
+++ '[' 0 -le 200 ']'
+++ return
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/which2.sh ']'
...
...
man bash
. you will find your answers therepam_env
in the PAM configuration forsu
? Is there a~oracle/.pam_environment
file?