简体   繁体   English

在ubuntu 14.04中添加.bashrc的路径

[英]add path to .bashrc in ubuntu 14.04

I seem to be having a problem setting path so that it permanently stays for a user. 我似乎在设置路径时遇到问题,以便永久保留给用户。 If I add to path by: 如果我添加到路径:

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

and then verfify by echo $PATH I can see that path gets temporarily added until the user closes the terminal. 然后通过echo $PATH我可以看到该路径被临时添加,直到用户关闭终端。 What is the correct way to add path to .bashrc and to echo $PATH ? 添加.bashrc路径和echo $PATH的正确方法是什么? Thank you :). 谢谢 :)。

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

In Ubuntu, .bashrc isn't always run by default. 在Ubuntu中,默认情况下并不总是运行.bashrc。 If you see the top of the comment in Ubuntu .bashrc code, 如果您在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

there is an option to run bash terminal as a login shell or not as describe above. 有一个选项可以将bash终端作为登录shell运行,如上所述。 With Ubuntu, gnome-terminal does not normally run as a login shell, so .bashrc should be run directly. 使用Ubuntu,gnome-terminal通常不作为登录shell运行,因此.bashrc应该直接运行。

By default, Ubuntu uses only .profile and default .profile has the following statements 默认情况下,Ubuntu仅使用.profile,默认.profile具有以下语句

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

This runs .bashrc if it is available assuming $BASH_VERSION is present in your environment. 如果可用,则运行.bashrc,假设您的环境中存在$ BASH_VERSION。 You can check for this by entering the command echo $BASH_VERSION, and it should display some information on version number and if $BASH_VERSION isn't set by default, .bashrc won't run on startup. 您可以通过输入命令echo $ BASH_VERSION来检查这一点,它应显示有关版本号的一些信息,如果默认情况下未设置$ BASH_VERSION,则.bashrc将不会在启动时运行。 Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM