I created an instance from the RHEL7 image.
Installed java at /opt/jdk1.7
and edited /etc/enviroment
to contain PATH=/opt/jdk1.7/bin:$PATH
Now performed a reboot.
Now when I try to login it allow to login using first part of email id then it ask for passpharse.
Now I am login as xyz
.
Now I type java -version
it gives me the correct version and also
echo $PATH
prints the correct path
.
Now I switch to root using sudo su
and whoami
prints root
and path
get change and it does not cantain the java bin path in it.
How to export variables globally ?
PS: one strange thing is after i switch to root
and again switch back to xyz
. the path
doesnt contain the path to java bin
Variable expansion does not work in /etc/environment. Only absolute value assignments can be put in this file. For e.g
T1=hithere
T2=X-$T1
after you reboot,
echo $T2
would print X-$T1 , though T1's value would be set as intended.
so put it in ~/.bashrc, ~/.profile, ~/.bash_profile, or /etc/profile etc