1

I am using the 12.04LST, and I am trying to install the oracle jdk7 manually.

Then I update the /etc/environment to set the PATH variable.

This is the original file content:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

And I update it as this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME="/usr/lib/jvm/jdk1.7"
PATH="$PATH:$JAVA_HOME/bin"

Then I make it work using:

source /etc/environment

Then I type java and javac, and it worked.

However after I reboot my computer, I was kept at the login screen.

Then I use ctrl+alt+f2 to go the terminal.

And update the /etc/envrionment like this:

/usr/bin/sudo /usr/bin/nano /etc/emvrionment to the following:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME="/usr/lib/jvm/jdk1.7"

Then I can login again.

Now I have two questions:

  1. Why I can not login if I add the line PATH="$PATH:$JAVA_HOME/bin" in /etc/envirionment?

  2. Is variables set in /etc/environment is available for all the user?

Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407
hguser
  • 315

2 Answers2

1

/etc/environment is not executed as a script but read as a configuration file, so no shell expansion is available, thus variables can't be read.

If you wan't to use variables, resort to use session-wide variables in ~/.pam_environment.

Reference

Eliran Malka
  • 1,245
  • 18
  • 36
0

Ok. I checked it - it must depends of PAM somehow, if write to /etc/environment this: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7/bin" and then source it, it will work fine and you'll be able to login

Fragles
  • 46