bashrc不加载在/ bin / bash shell中

当我ssh进入一个服务器(4.3.3-2-ARCH),我的.bashrc没有加载(但是,我可以通过采购它手动加载)。

我的主文件夹中没有任何其他文件,例如.profile。 shell也是正确的

$ echo $SHELL /bin/bash 

当我使用ssh -t myserver /bin/bashlogin时,我的.bashrc加载正确。

在SSH详细模式下,我看到/etc/bash.bashrc和〜/ .bashrc是使用最后一条命令加载的。 当使用默认的ssh命令时,它们都没有被加载…

我应该configuration什么使用默认的ssh命令加载.bashrc(和/etc/bash.bashrc)?

~/.bashrc文件被加载用于交互式非loginshell,这就是为什么运行/bin/bash从ssh工作正如你所期望的。

对于loginshell(除其他外)〜/ .bash_profile被读取。 通常你的~/.bash_profile包含类似的东西

 if [ -f ~/.bashrc ]; then . ~/.bashrc fi 

这确保了如果你的shell是一个loginshell,加载~/.bashrc

如果你的~/.bash_profile包含上面的内容,并且~/.bashrc没有被加载,你可以像往常一样使用set -x来debugging脚本。

通常当用户被创build时,它会将一堆文件复制到你的新的home目录(如果你select创build的话)。

您可以检查这些文件的/etc/skel目录。 应该有你期望的.bash_profile

Bash根据shell的调用读取一组文件:

  • loginshell:基本上是一个连接到tty并来自authentication过程的shell。 这种shell读取/ etc / profile,〜/ .bash_profile,〜/ .bash_login和〜/ .profile
  • 非login – 交互式shell:在没有身份validation过程的情况下打开的交互式shell。 这种shell读取/etc/bash.bashrc和〜/ .bashrc

你可以find更多的信息:男子bash,部分调用