Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2862

bash起動に関して

$
0
0
なんで以下の順番でプロファイルを読み込んでいるのかわからなかった。。。 気になって調べてみた。 bashコマンドのソースに記載があった。 version:4.2 SYS_PROFILEは、「/etc/profile」のこと shell.c /* 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; } pathnames.h /* 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 util.c if (shell) *shell = p->pw_shell; return 0; } systemdが、ログイン時に「/etc/passwd」ファイルを読み込んで ユーザのシェル情報を取得している。 それをもってシェル設定を行っている模様。。。。

Viewing all articles
Browse latest Browse all 2862

Trending Articles