ubuntu中 .bashrc 没有被执行(.bashrc not executed when opening new terminal)

.bashrc 没有被执行

当我在Ubuntu 12.04中打开新的终端窗口时,.bashrc中的代码不执行。 创建.bash_aliases文件时,我注意到了这一点。 当我打开一个新终端时,别名没有显示。 但是,当我输入source .bashrc时,别名确实出现了。

.bashrc应该在每次打开新的终端窗口时运行,对吗?

我如何做到这一点?

如何解决

它不一定运行; 在标准.bashrc的顶部是此注释:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

我相信可以选择是否将bash终端作为登录shell运行。 在Ubuntu中,gnome-terminal通常不作为登录shell运行,因此.bashrc应该直接运行。

对于登录外壳程序(如虚拟终端),通常运行〜/.profile文件,除非您具有〜/.bash_profile或〜/.bash_login,但默认情况下不存在。 默认情况下,Ubuntu仅使用.profile

标准〜/ .profile中包含以下内容:

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

如果可用,它将运行.bashrc-假定环境中存在$ BASH_VERSION。 您可以通过输入命令echo $ BASH_VERSION进行检查,它应该显示一些有关版本号的信息-不能为空。


原文: [.bashrc not executed when opening new terminal] https://askubuntu.com/questions/161249/bashrc-not-executed-when-opening-new-terminal

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值