最終更新:2019-03-12 (火) 17:22:05 (1870d)
Bash/設定ファイル
http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
主な違い
.bash_profile (.profile)
.bashrc
- 対話モードの bash を起動する時に毎回実行 (インタラクティブシェル)
- 環境変数でない変数を設定する (export しない変数)
- aliasを定義する
- シェル関数を定義する
- コマンドライン補完の設定をする
起動時の読み込み順
Ubuntu
ログイン時
- .bash_profile (なければ.bash_login?、更に無ければ.profile)
- .bashrc
Bash起動時
CentOS
ログイン時
- Linux/etc/profile
- .bash_profile (なければ.bash_login?、更に無ければ.profile)
Bash起動時
ログアウト時
- .bash_logout?
Cygwin Terminal
- C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
- Cygwin/etc/profile
- Cygwin/etc/bash.bashrc?
ディレクトリ別
Linux/etc
ホームディレクトリ
- .bash_profile
- .bashrc
- .profile (Ubuntu)
- .bash_logout?
スケルトン
用途
- .bash_profile - ログイン時に一度だけに実行される (--loginをつけると読み込まれる)
- .bashrc - シェルが起動したときに実行される
- エイリアスとかはここに書く
- 全Bashで設定したい設定を記述
- .bash_history? - bashで実行したコマンド履歴
- .bash_logout? - ログアウト時に実行
- /etc/profile
- /etc/profile.d
- /etc/bashrc