我正在运行 RHEL5。我将简单的别名命令添加到~/.bashrc. 当我启动一个新终端时,没有任何反应,但source ~/.bashrc可以正常工作,所以我知道语法是正确的。我还进行了修改/源代码测试~/.bash_profile,但它也不会在终端启动时执行。 ~/.bash_login并且~/.profile在我的系统上不存在。
这是我的~/.bashrc
# .bashrc
# Source global definitions if [ -f /etc/bashrc ]; then
. /etc/bashrc fi
# User specific aliases and functions
alias hi=hello
Run Code Online (Sandbox Code Playgroud)
和我的~/.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
Run Code Online (Sandbox Code Playgroud)
~/.bashrc仅针对非登录 shell 执行,请检查您的终端设置:
Edit -> Profile Preferences -> Title and Command -> "Run command as a login shell
如果可用,则通常~/.profile加载(如果 - 假设存在于您的环境中)。~/.bashrc$BASH_VERSION
请记住,~/.profile如果您家中存在~/.bash_profile或存在,则该信息将被忽略~/.bash_login,并且由于它被忽略,~/.bashrc因此也没有来源。