I need to setup some system-wide environment variables for my Jetty server.

But where to put them? There seem to be 2 choices

/etc/profile or

/etc/profile.d? Which are the differences between the two?

link|improve this question

71% accept rate
feedback

1 Answer

up vote 2 down vote accepted

/etc/profile.d is used so you can break out some of the setting that go in profile.

For instance instead of putting settings for vi in /etc/profile, I can put them in /etc/profile.d/vi

Per the comment at the top of /etc/profile

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

and the actual profile.d execution bit

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null 2>&1
        fi
    fi
done
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.