Назад | Перейти на главную страницу

Переменные среды, специфичные для сервера - / etc / profile или /etc/profile.d

Мне нужно настроить некоторые общесистемные переменные среды для моего сервера Jetty.

Но куда их девать? Кажется, есть 2 варианта

/etc/profile или

/etc/profile.d? В чем разница между ними?

/etc/profile.d используется, чтобы вы могли отделить некоторые настройки профиля.

Например, вместо того, чтобы помещать настройки для vi в / etc / profile, я могу поместить их в /etc/profile.d/vi

За комментарий в верхней части / 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.

и фактический бит выполнения profile.d

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