Centos7が/etc/profileと/etc/bashrcで/etc/profile.dスクリプトを実行するのはなぜですか?

Centos7が/etc/profileと/etc/bashrcで/etc/profile.dスクリプトを実行するのはなぜですか?

Centos7には次のものがあります/etc/profile

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

そして次の/etc/bashrc(ランニングから~/.bashrc):

    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . "$i"
            else
                . "$i" >/dev/null
            fi
        fi
    done

Debian と Ubuntu はこれを でしか実行しませんが/etc/profile、これが私が期待するものです。

  • Centosが両方で実行するのはなぜですか?
  • なぜ違いがありますかsh.local

ベストアンサー1

最初の問題についてはよくわかりませんが、その理由は、Debianベースのシェルが呼び出されたときに、デフォルトではRed Hatベースのシェルよりもsh「もっと愚かな」動作だからだと思います。bashsh

これ赤い帽子エラーこれはsh.localSAを保証するためのものであることを説明します。すべて他のものはで発見されました/etc/profile.d

おすすめ記事