2016-04-07 42 views

回答

1

通常在Ubuntu ${HOME}/.profile來源${HOME}/.bashrc

實例從我的股票${HOME}/.profile

# if running bash 
if [ -n "$BASH_VERSION" ]; then 
    # include .bashrc if it exists 
    if [ -f "$HOME/.bashrc" ]; then 
     . "$HOME/.bashrc" 
    fi 
fi 

${HOME}/.profile其來源在會話登錄。

有一件事情你可能想知道。據我所知,${HOME}/.bashrc也來源於每個登錄shell。

這個怪癖將導致${HOME}/.bashrc兩次來源;一旦登錄會話並登錄登錄shell(啓動終端)。

但我不禁想知道:如果你的.profile位於/etc是你${HOME}/etc/?這會導致問題,因爲你沒有寫權限,並且一切都是相對的${HOME}

希望它有幫助。

UPDATE

/etc/skel/.profile:

# ~/.profile: executed by the command interpreter for login shells. 
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login 
# exists. 
# see /usr/share/doc/bash/examples/startup-files for examples. 
# the files are located in the bash-doc package. 

所以,如果使用bash在${HOME}有效地覆蓋您的.profile.bash_profile

總之,這一切都取決於你的/etc/.profile發生了什麼。

+0

優秀。謝謝。我只需要添加到bashrc。我是Linux的新手。 –

+0

樂意幫忙:-) – totoro

相關問題