わかりやすい説明があったので
https://blog1.mammb.com/entry/2019/12/01/090000#%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E3%82%B7%E3%82%A7%E3%83%AB%E3%81%A8%E3%81%AF
なんで以下の順番でプロファイルを読み込んでいるのかわからなかった。。。
気になって調べてみた。
bashコマンドのソースに記載があった。
version:4.2
SYS_PROFILEは、「/etc/profile」のこと
/* Execute /etc/profile and one of the personal login shell
initialization files. */
if (no_profile == 0)
{
maybe_execute_file (SYS_PROFILE, 1);
if (act_like_sh) /* sh */
maybe_execute_file ("~/.profile", 1);
else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
(maybe_execute_file ("~/.bash_login", 1) == 0)) /* bash */
maybe_execute_file ("~/.profile", 1);
}
sourced_login = 1;
}
/* The default login shell startup file. */
# define SYS_PROFILE "/etc/profile"
# この「SYS_PROFILE」が「/etc/profile」のこと
# 宣言は、
Redhatでログインして、psコマンドを実行すると、bashだけが実行されている。
なのでbash関連のファイルが読み込まれている。
OS上で「~.profile」を作成しただけでは、bashがまた起動された。
仕方ないので「/etc/passwd」のシェルの部分を変更した。
そうしたら「.profile」が読まれた。
ということは、ユーザがログインする際に、/etc/passwdをチェックしているんだなぁということが
わかった。
誰が犯人なんだろうって思って調査開始。
よくよく考えてみたら
Redhatのログインを制御しているのってsystemdだと仮定して再調査
/etc/passwdから以下のファイルを読んでいることがわかった。
version:systemd 219
if (shell)
*shell = p->pw_shell;
return 0;
}
systemdが、ログイン時に「/etc/passwd」ファイルを読み込んで
ユーザのシェル情報を取得している。
それをもってシェル設定を行っている模様。。。。