GNU/Linux >> Linux の 問題 >  >> Linux

ログインシェルと非ログインシェルの間のConfファイルの読み取りとは何ですか?

それらは.bash_profileであることがわかりました 、 .bashrc .bash_login .profile

それらの間の読み取りシーケンスは何ですか?

承認された回答:

基本的に、ログインシェルの場合は、 / etc / profileをソースします。 次に.bash_profile 。ログインシェルではないが、ターミナルにいる場合は、 /etc/bash.bashrcをソースします。 次に.bashrc

しかし、実際にはもっと複雑です。

マニュアルページの読み方:

if bash_mode; then
    if login_shell; then
        if test -e /etc/profile; then source /etc/profile; fi
        if test -e .bash_profile; then source .bash_profile
        elif test -e .bash_login; then source .bash_login
        elif test -e .profile; then source .profile; fi
    elif interactive_shell || remote_shell; then
        if test -e /etc/bash.bashrc; then source /etc/bash.bashrc
        if test -e .bashrc; then source .bashrc; fi
    elif test -n "$BASH_ENV"; then
        source "$BASH_ENV"
    fi
elif sh_mode; then
    if login_shell; then
        if test -e /etc/profile; then source /etc/profile; fi
        if test -e .profile; then source .profile; fi
    elif interactive_shell; then
         if test -n "$ENV"; then
             source "$ENV"
         fi
    fi
fi

シェルが-bashとして実行されるときはいつでもログインシェルです (マイナス記号に注意してください)または -l <​​/ code> オプション。これは通常、 loginを使用してログインしたときに発生します コマンド(Linux仮想コンソールがこれを実行します)、sshを介して、またはターミナルエミュレータで「ログインシェル」オプションが有効になっている場合。

標準入力がターミナルである場合、またはbashが -i で開始された場合は常に、インタラクティブシェルです。 オプション。シェルがログインシェルでもある場合、bashはシェルがインタラクティブであるかどうかをチェックしないことに注意してください。このため、 .bash_profile 通常、ソース .bashrcへのコードが含まれています 、したがって、インタラクティブシェルとログインシェルの間で同じ設定を共有できます。


Linux
  1. $(stuff)と `stuff`の違いは何ですか?

  2. 組み込みコマンドとそうでないコマンドの違いは?

  3. [[$ a ==Z*]]と[$a==Z *]の違いは?

  1. / sbin/nologinと/bin/ falseの違いは何ですか?

  2. .exrcと.vimrcの違いは?

  3. 通常のユーザーとシステムユーザーの違いは何ですか?

  1. Linux –`su-`と`su–login`の違いは何ですか?

  2. AwkのPrintとPrintfの違いは何ですか?

  3. Nohup とアンパサンドの違いは何ですか