Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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 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"
            . "$i" >/dev/null 2>&1
share|improve this answer

Your Answer


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.