1 概述
我们知道 Bash 的配置文件有两个,分别是.bash_profile
和 .bashrc
,那么他们有什么不同呢?
2 .bash_profile
用户登录时,会加载该文件。
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
如果.bashrc
文件存在,则会加载.bashrc
。
3 .bashrc
当我们启动一个 Bash
会话时,将会加载改文件。
# User specific aliases and functions
alias ls='ls -a'
注意:如果因为 Bash 配置问题导致无法登录,那么登录后,立即按下 Ctrl+C
,可以防止配置文件重新加载。