4

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 
1
  • what happens if you set the JAVA_HOME and GROOVY_HOME variables, then set the path all at once with this: export PATH=$PATH:$JAVA_HOME:$GROOVY_HOME Commented May 28, 2013 at 14:03

1 Answer 1

5

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.

JAVA_HOME=/usr/jdk/instances/jdk1.7.0 GROOVY_HOME=/usr/local/bin/groovy-2.1.3 PATH=${PATH}:${GROOVY_HOME}/bin:${JAVA_HOME}/bin export PATH 

Solaris 11, where bash is the default shell will work ok with your profile, but older Solaris version may not parse the export 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.

solaris:~$ grep PATH .* .profile:export PATH=/usr/bin:/usr/sbin 

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.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.