2009年6月14日 星期日

bash介紹

設定檔通常會放在家目錄 (~/)下面,看自己 shell 的方法為

$> echo $SHELL


  • .bash_login

.bash_login 源自 C shell 的 .login、.profile 源自 Bourne shell 的 .profile,兩者對於 bash 的意義相等。

當使用者 login 進來的時候,如果設定的 shell 是 bash 則會依照 .bash_profile > .bash_login > .profile 讀取,讀取到其中一個之後就會跳過剩餘的讀取。


[NOTE]
修改完 .bash_profile 完並不能立即看到結果,快速的方法是直接下 command 重新執行 .bash_profile 中所寫的命令。

$> source .bash_profile
  • .bashrc

當在命令列上執行 bash 時,bash 會去讀取 .bashrc 檔,用途在將登入系統時執行的命令跟執行subshell 所需執行的命令區隔開來。

$> source .bashrc

或是將以下code加在 .bash_profile 中:

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

如此可以讓 login 時也會去讀取 .bashrc 的內容

  • .bash_logout

顧名思義,logout 時就會去執行 .bash_logout 中所寫的命令,較少見。
一般為拿來清除一些紀錄檔或是紀錄登出的狀態。


[ref] : Bash - DebianWiki

沒有留言:

張貼留言