I have installed JDK and Groovy on my Solaris 11 machine. I would now like to set things up so that the PATH variable would contain the bin directories whenever I open a shell.
It is my understanding that the following lines added at the end of the /etc/profile
file should do the trick.
JAVA_HOME=/usr/jdk/instances/jdk1.7.0
PATH=${PATH}:${JAVA_HOME}/bin
GROOVY_HOME=/usr/local/bin/groovy-2.1.3
PATH=${PATH}:${GROOVY_HOME}/bin
export PATH
However, when I restart my putty session, only the JAVA_HOME and GROOVY_HOME variables are affected. The PATH variable stays the same, e.g.
/usr/bin:/usr/sbin
I am wondering if there is another script that runs after /etc/profile, that might override the PATH variable. But I have no idea where to look.
Or is there another problem?
As porposed in a comment, I tried to use the following lines instead, but unfortunatelly with the same effect.
JAVA_HOME=/usr/jdk/instances/jdk1.7.0
GROOVY_HOME=/usr/local/bin/groovy-2.1.3
export PATH=${PATH}:${GROOVY_HOME}/bin:${JAVA_HOME}/bin
Best Answer
Check
/etc/default/login
for login shells. You can force an initial path there.Adding your variables to /etc/profile should work, depending on the version of Solaris running. A more portable, for Solaris, way of doing it would be to separate setting the PATH variable and exporting it.
Solaris 11, where
bash
is the default shell will work ok with your profile, but older Solaris version may not parse theexport PATH=...
syntax as expected, or at all.Also, keep in mind that you're only changing the initial PATH for users.
/etc/profile
is read before a user's.profile
is read.By default, Solaris users will usually end up with their own
.profile
file that contains a default PATH.Since this .profile is being read in after the
/etc/profile
that you've modified, your changes to$PATH
will be discarded and the user's entries will take over.You can add these changes for new users by editing the file
/etc/skel/.profile
, but to make the changes permanent for existing users, you would need to edit their individual .profiles, or overwrite them if they haven't edited them themselves.