我用的是ubuntu14.10操作系統,最近喜歡上了python,想搞一個python IDE,從網上查了一下,最終確定使用vim的python-mode插件,還是習慣用vim,不想在現在的賬戶下測試,於是就新建了一個賬戶test,su - test進去後發現ls顏色根本不對,全是黑底白字,悲了個催的,於是就把默認賬戶下的.bashrc文件複製了一份過來。發現還是不行。仔細看了一下bahsrc文件,裏面確實有關於顏色配置的語句,如下:
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
後來手工source了一下,果然成功了,原來ubuntu下面用su - 切換到新用戶的時候不會執行bashrc文件,於是就把上面那一段代碼粘貼到.bash_profile文件裏面了,果然成功了。
結論:ubuntu 中,su - user命令切換到新用戶的時候會執行bash_profile文件不會執行bashrc文件。