○Linuxでbashがログインシェルとして起動する場合
ユーザ環境の設定ファイルは次の順番で読み込まれます。
1./etc/profileを読み込む
2.~/.bash_profile, ~/.bash_login, ~/.profile
の順でファイルを検索して、最初に見つかったファイルを読み込む
~/.bash_profileが見つかった場合
3.~/.bash_profileから~/.bashrcを読み込む
4.~/.bashrcから/etc/bashrcを読み込む
RedHat AS4のデフォルトの~/.bash_profile
$ cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH unset USERNAME
RedHat AS4のデフォルトの~/.bashrc
$ cat ~/.bashrc # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
○bashをログイン時以外に起動した場合
1.~/.bashrcを読み込む
2.~/.bashrcから/etc/bashrcを読み込む
○設定ファイルの使い分け
/etc/profile:全ユーザに対して設定したい場合に使用。一回設定しておけば良い設定に使用。
~/.bash_profile:ユーザ個別に設定したい場合に使用。一回設定しておけば良い設定に使用。
~/.bashrc:エイリアス設定などシェル起動時に毎回設定する必要がある場合に使用。