path - Linux

This is a discussion on path - Linux ; I am using my linux version of bash. How could I add usr/local to the path, or any directory location to the path using the PATH variable? I want to use two compilers and have one in usr local. The ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: path

  1. path

    I am using my linux version of bash. How could I add usr/local to the
    path, or any directory location to the path using the PATH variable? I want
    to use two compilers and have one in usr local. The one in usr works fine.

    Bill



  2. Re: path

    On 2008-05-29, Bill Cunningham wrote:
    > I am using my linux version of bash. How could I add usr/local to the
    > path, or any directory location to the path using the PATH variable? I want
    > to use two compilers and have one in usr local. The one in usr works fine.


    In your $HOME/.bashrc (or $HOME/.bash_profile), modify any
    existing PATH assignment or, if there is none, add this line:

    PATH=$PATH:/usr/local/bin

    To add it for your current shell, execute that line at the
    prompt.

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  3. Re: path

    On Thu, 29 May 2008 19:09:10 GMT, Bill Cunningham wrote:
    > I am using my linux version of bash. How could I add usr/local to the
    > path, or any directory location to the path using the PATH variable? I want
    > to use two compilers and have one in usr local. The one in usr works fine.


    export PATH=$PATH:/usr/local

    If you want /usr to be checked first

    export PATH=/usr/local:$PATH

    Then you need to decide where you want to put the export, system wide
    or for one user.

    For extra points:
    man $(basename $SHELL)

  4. Re: path


    "Bit Twister" wrote in message
    news:slrng3u7hc.6qb.BitTwister@wm81.home.test...

    > export PATH=$PATH:/usr/local
    >
    > If you want /usr to be checked first
    >
    > export PATH=/usr/local:$PATH
    >
    > Then you need to decide where you want to put the export, system wide
    > or for one user.
    >
    > For extra points:
    > man $(basename $SHELL)


    Here's the way I've understood it. I must be wrong.
    PATH=/usr/bin:/usr/local/bin;$PATH

    export PATH

    And my .bash_profile looks something like that. Can I run some commands from
    /usr/bin and some from /usr/local/bin ? Of course you need a default and
    extra compiler. But in the case of searching for files I would like to have
    several directories in my path.

    Bill



  5. Re: path

    On Thu, 29 May 2008 23:55:40 GMT, Bill Cunningham wrote:
    >
    > Here's the way I've understood it. I must be wrong.
    > PATH=/usr/bin:/usr/local/bin;$PATH

    ^
    |
    Needs to be colon-------------+-----not semicolon

    > export PATH
    >
    > And my .bash_profile looks something like that. Can I run some commands from
    > /usr/bin and some from /usr/local/bin ?


    Assuming the same name, sure, if you hard code the path.
    Take the Firefox command example on my system.

    $ type -a firefox
    firefox is /usr/local/bin/firefox
    firefox is /usr/bin/firefox

    Here I can run /usr/local/bin/firefox which is 3.0.rc1, or I can run
    /usr/bin/firefox which is 2.0.0.14

    If I enter just firefox, /usr/local/bin/firefox is executed because I have
    /usr/local/bin/ before /usr/bin/ in my PATH variable.


    > Of course you need a default and extra compiler.


    Yes, and without specifying which, first one found in the PATH, is used.
    Use the command
    type cmd_here
    to see where the cmd_here will be found/used.

    > But in the case of searching for files I would like to have
    > several directories in my path.


    Explain searching for files. When you run a command, alias, function,
    builtin, $PATH is checked. First one found wins.

    I use "type cmd" to see what cmd will be selected.

    Here is another example:

    type -a echo


  6. Re: path


    "Bit Twister" wrote in message
    news:slrng3uncs.c7h.BitTwister@wm81.home.test...
    > On Thu, 29 May 2008 23:55:40 GMT, Bill Cunningham wrote:
    >>
    >> Here's the way I've understood it. I must be wrong.
    >> PATH=/usr/bin:/usr/local/bin;$PATH

    > ^
    > |
    > Needs to be colon-------------+-----not semicolon
    >
    >> export PATH

    [snip]

    Are you pointing to the usr ? The semicolon is in front of the $. I've
    tried man bash and it is informative and a bit confusing.

    Bill



  7. Re: path

    On Fri, 30 May 2008 23:26:06 GMT, Bill Cunningham wrote:
    >
    > "Bit Twister" wrote in message
    > news:slrng3uncs.c7h.BitTwister@wm81.home.test...
    >> On Thu, 29 May 2008 23:55:40 GMT, Bill Cunningham wrote:
    >>>
    >>> Here's the way I've understood it. I must be wrong.
    >>> PATH=/usr/bin:/usr/local/bin;$PATH

    >> ^
    >> |
    >> Needs to be colon-------------+-----not semicolon
    >>
    >>> export PATH

    > [snip]
    >
    > Are you pointing to the usr ?


    Nope, semicolon before the $PATH.

    > The semicolon is in front of the $.


    You are quite correct. It should be a colon, not a semicolon.

  8. Re: path

    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi

    # User specific environment and startup programs

    setterm -blank off
    PATH=$PATH:$HOME/bin
    BASH_ENV=$HOME/.bashrc
    USERNAME="root"

    export USERNAME BASH_ENV PATH

    This is a copy of my .bash_profile. I added the setterm switch. Set up as it
    is, would it take a /usr/local/bin of some kind to look at commands in
    usr/local/bin ? What about sbin ?

    Bill



  9. Re: path

    On Sat, 31 May 2008 16:40:26 GMT, Bill Cunningham wrote:
    > # .bash_profile
    >
    > # Get the aliases and functions
    > if [ -f ~/.bashrc ]; then
    > . ~/.bashrc
    > fi
    >
    > # User specific environment and startup programs
    >
    > setterm -blank off
    > PATH=$PATH:$HOME/bin
    > BASH_ENV=$HOME/.bashrc
    > USERNAME="root"
    >
    > export USERNAME BASH_ENV PATH
    >
    > This is a copy of my .bash_profile. I added the setterm switch. Set up as it
    > is, would it take a /usr/local/bin of some kind to look at commands in
    > usr/local/bin ? What about sbin ?


    If you want the sbin paths, add them. My PATH

    $ echo $PATH
    /home/bittwister/work:/sbin:/usr/sbin:/usr/local/bin:\
    :/bin:/usr/bin:/usr/bin/X11:/usr/games:/usr/lib/qt4/bin\
    :/local/bin:/home/bittwister/bin

    NOTE:
    I added the \ and folded the output to keep my news reader from complaining.

+ Reply to Thread