今天想 在 .bashrc 中配置一段自動(dòng)啟動(dòng) ssh-agent 的腳本,結(jié)果總是沒有自動(dòng)運(yùn)行;才發(fā)現(xiàn)我的 bashrc 腳本沒有自動(dòng) 加載
后來才發(fā)現(xiàn)是這次裝的深度系統(tǒng)(deepin)默認(rèn)沒有 ~.PRofile
腳本, 去看看之前的Ubuntu系統(tǒng)里面都默認(rèn)是有這個(gè)腳本的,而 ~.bashrc
腳本則是通過 .profile 來加載的
1. linux系統(tǒng)加載bash配置腳本的順序如果新建一個(gè)用戶, 在其 $HOME 目錄下會(huì)自動(dòng)創(chuàng)建 .profile 腳本嗎?
.bashrc 文件本身在 *nix 系統(tǒng)下就不會(huì)自動(dòng)加載,一般都是通過 .profile 間接加載的
一般,系統(tǒng)會(huì)按下面的順序加載
/etc/profile~/.bash_profile~/.bash_login~/.profile
如果你的.bashrc
沒有自動(dòng)加載,就新建 ~/.profile
# ~/.profile: executed by Bourne-compatible login shells.if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fimesg n
當(dāng)然如果, 已經(jīng)有了
.bash_profile
or.bash_login
, 那么這個(gè).profile
文件也不會(huì)被加載。 總之,是把 此段代碼寫到 已經(jīng)存在的 最先被加載到的那個(gè)配置中。
refer to :
http://askubuntu.com/questions/260682/bashrc-not-autosourced-in-12-04-ltshttp://apple.stackexchange.com/questions/12993/why-doesnt-bashrc-run-automatically
2. Difference Between .bashrc & .bash_profile.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
當(dāng)你直接在機(jī)器login界面登陸、使用ssh登陸或者su切換用戶登陸時(shí),.bash_profile 會(huì)被調(diào)用來初始化shell環(huán)境Note:.bash_profile文件默認(rèn)調(diào)用.bashrc文件
你已經(jīng)登陸系統(tǒng)后,每打開一個(gè)新的Terminal時(shí),.bashrc 都會(huì)被再次調(diào)用。
若要配置環(huán)境變量之類,最保險(xiǎn)是寫在 .bashrc 文件中。因?yàn)椴还苁堑顷戇€是不登陸,該文件總會(huì)被調(diào)用
refer to :
http://upgirl.blog.51cto.com/3744514/1140176
新聞熱點(diǎn)
疑難解答
圖片精選