1

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?

Trollhorn
  • 203
  • 3
  • 10

1 Answers1

3

/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
rfelsburg
  • 767
  • 3
  • 7