Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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