On Debian and other systems that use PAM (which is most of them nowadays), you can set environment variables (including PATH
) in /etc/environment
. This will work for any login method that uses the pam_env
module (either in the auth
section or in the session
section); on Debian that should be all of them (at least the ones that provide ways to log in and run commands).
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.
Best Answer
Make
/etc/profile
source/etc/bash.bashrc
by adding[ -f /etc/bash.bashrc ] && . /etc/bash.bashrc
to the end of/etc/profile
, then add your path changes to/etc/bash.bashrc
withPATH=$PATH:/some/other/path