在ubuntu 14.04中添加.bashrc的路径



我似乎有一个问题设置路径,使它永久为用户保留。如果我添加到path by:

export PATH=/home/cmccabe/Desktop/NGS/picard-tools-1.139:$PATH

,然后通过echo $PATH验证,我可以看到该路径被临时添加,直到用户关闭终端。给.bashrcecho $PATH添加路径的正确方法是什么?谢谢。

export PATH=$PATH:/home/cmccabe/Desktop/NGS/picard-tools-1.139 >> .bashrc

在Ubuntu中,.bashrc并不总是默认运行。如果你在Ubuntu .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应该直接运行。

默认情况下,Ubuntu只使用。profile,默认的。profile有以下语句

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

如果环境中存在$BASH_VERSION,则运行.bashrc。您可以通过输入echo $BASH_VERSION命令来检查,它应该显示一些关于版本号的信息,如果$BASH_VERSION没有默认设置,那么.bashrc将不会在启动时运行。希望这对你有帮助

最新更新