简体   繁体   中英

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. What is the correct way to add path to .bashrc and to 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. If you see the top of the comment in Ubuntu .bashrc code,

# ~/.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. With Ubuntu, gnome-terminal does not normally run as a login shell, so .bashrc should be run directly.

By default, Ubuntu uses only .profile and default .profile has the following statements

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. 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. Hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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