異なる OS シェルの環境変数の実行順序を知ることは、システム管理者にとって非常に重要です。これは、cron ジョブの設定や、対話型シェルで実行されるコマンドと非対話型シェルを使用するバッチ ジョブの違いを理解するのに役立つ場合があります。
1.シェル:CSH
起動 (順序):
--> .cshrc (always) --> .login (login shells)
終了:
--> .logout (login shells)
その他:
.history (saves history based on "$savehist")
2.シェル:tcsh
起動 (順序):
--> /etc/csh.cshrc (always) --> /etc/csh.login (login shells) --> .tcshrc (always) --> .cshrc (if no .tcshrc file is present) --> .login (login shells)
終了:
-->.logout (login shells)
その他:
--> .history (saves history based on "$savehist") --> .cshdirs (saves directory stack)
3.シェル:sh
起動 (順序):
--> /etc/profile (login shells)
終了:
Any command or script specified using the command: trap "command" 0
その他:
--> .profile (login shells)
4.シェル:ksh
起動 (順序):
--> /etc/profile (login shells) --> .profile (login shells) --> $ENV (always, if it is set)
終了:
Any command or script specified using the command: trap "command" 0
5.シェル:bash
起動 (順序):
--> /etc/profile (login shells) --> .bash_profile (login shells) --> .profile (login if no .bash_profile file is present) --> .bashrc (interactive non-login shells) --> $ENV (non-interactive shells)
終了:
--> .bash_logout (login shells)
その他:
--> .inputrc (readline initialization)
6.シェル:zsh
起動 (順序):
--> .zshenv (always, unless the -f option is specified) --> .zprofile (login shells) --> .zshrc (interactive shells, unless the -f option is specified) --> .zlogin (login shells)
終了:
--> .zlogout (login shells)