I’m using knoppix 7.0.3 and trying to set the PATH environment variable. According to the official Ubuntu documentation, /etc/environment should be the preferred place for this. So I added these lines in the file:
JAVA_HOME="/usr/lib/jvm/java-6-sun"
GRAILS_HOME="/home/knoppix/grails"
PATH="${PATH}:${JAVA_HOME}/bin:${GRAILS_HOME}/bin"
But after rebooting the system, the file just reverted to the original one (I was using persistent storage).
Then after some Googling, I tried to edit ~/.profile like this:
export JAVA_HOME="/usr/lib/jvm/java-6-sun"
export GRAILS_HOME="/home/knoppix/grails"
export PATH=$PATH:$JAVA_HOME/bin:$GRAILS_HOME/bin
This time, the first two variables got set (echoed in console), but the PATH didn’t. It was still the default one when I echoed. What’s wrong?
The problem is that your
PATHis being overwritten during initialization of bash, after reading.profile.From the manpage of bash:
From your experience, it is apparent that if
.bashrcdoesn’t exist, bash is trying to setPATHto a default value (I would appreciate if someone confirms this).As we discussed in the comments on your question, adding the
exportcommands to.bashrc(and thus creating the file) solves the problem. Alternatively, you can addto the end of your
.bashrcfile for the same effect.