それらは.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
へのコードが含まれています 、したがって、インタラクティブシェルとログインシェルの間で同じ設定を共有できます。