Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
Hi folks, BLFS 6.1 On running following command # echo $PATH Code: /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:. Which file shall I edit to change it as; /usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin Please advise. TIA BR satimis...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787

    A question on PATH


    Hi folks,

    BLFS 6.1

    On running following command
    # echo $PATH
    Code:
    /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
    Which file shall I edit to change it as;
    /usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin

    Please advise. TIA

    BR
    satimis

  2. #2
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    To set PATH var you may want to add the following line to your .bashrc file in your home directory (or to /root directory if you want this PATH to be available to all users)
    Code:
    export PATH=$PATH:/add/your/path

  3. #3
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787
    Hi RustamB,

    Tks for your advice. However I can't understand follows;

    1)
    On FC3 Host
    # echo $PATH
    Code:
    /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/satimis/bin
    # cat /root/.bash_profile
    Code:
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    PATH=$PATH:$HOME/bin
    
    export PATH
    unset USERNAME
    How can "PATH=$PATH:$HOME/bin" showed "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/satimis/bin" on running "echo $PATH"?


    2)
    BLFS 6.1
    # echo $PATH
    Code:
    /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
    # cat /mnt/lfs/root/.bash_profile
    Code:
    <snip>
    append &#40;&#41; &#123;
      # First remove the directory
      local IFS='&#58;'
      local NEWPATH
      for DIR in $PATH; do
         if &#91; "$DIR" != "$1" &#93;; then
           NEWPATH=$&#123;NEWPATH&#58;+$NEWPATH&#58;&#125;$DIR
         fi
      done
    
      # Then append the directory
      export PATH=$NEWPATH&#58;$1
    &#125;
    
    if &#91; -f "$HOME/.bashrc" &#93; ; then
            source $HOME/.bashrc
    fi
    
    if &#91; -d "$HOME/bin" &#93; ; then
      append $HOME/bin
    fi
    
    unset append
    
    # End ~/.bash_profile
    The path is not showed there. How "echo $PATH" displayed "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:." ?

    Please advise. TIA

    BR
    satimis

  4. #4
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787
    Quote Originally Posted by satimis
    Hi RustamB,

    Tks for your advice. However I can't understand follows;

    1)
    On FC3 Host
    # echo $PATH
    Code:
    /usr/kerberos/sbin&#58;/usr/kerberos/bin&#58;/usr/local/bin&#58;/usr/bin&#58;/bin&#58;/usr/X11R6/bin&#58;/home/satimis/bin
    # cat /root/.bash_profile
    Code:
    # .bash_profile
    
    # Get the aliases and functions
    if &#91; -f ~/.bashrc &#93;; then
            . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    PATH=$PATH&#58;$HOME/bin
    
    export PATH
    unset USERNAME
    How can "PATH=$PATH:$HOME/bin" showed "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/satimis/bin" on running "echo $PATH"?


    2)
    BLFS 6.1
    # echo $PATH
    Code:
    /usr/gnu/bin&#58;/usr/local/bin&#58;/bin&#58;/usr/bin&#58;.
    # cat /mnt/lfs/root/.bash_profile
    Code:
    <snip>
    append &#40;&#41; &#123;
      # First remove the directory
      local IFS='&#58;'
      local NEWPATH
      for DIR in $PATH; do
         if &#91; "$DIR" != "$1" &#93;; then
           NEWPATH=$&#123;NEWPATH&#58;+$NEWPATH&#58;&#125;$DIR
         fi
      done
    
      # Then append the directory
      export PATH=$NEWPATH&#58;$1
    &#125;
    
    if &#91; -f "$HOME/.bashrc" &#93; ; then
            source $HOME/.bashrc
    fi
    
    if &#91; -d "$HOME/bin" &#93; ; then
      append $HOME/bin
    fi
    
    unset append
    
    # End ~/.bash_profile
    The path is not showed there. How can "echo $PATH" display "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:." ?

    Please advise. TIA

    BR
    satimis

  5. #5
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    The path is not showed there. How can "echo $PATH" display "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:." ?
    PATH is also set somewhere else, but I'm not sure where and why.

    When you do the following
    Code:
    export PATH=$PATH&#58;/your/path
    you ADD /your/path to existing PATH variable. If you want to entirely replace it with your PATH variable then run
    Code:
    export PATH=/your/path

  6. #6
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787
    Hi RustamB,

    Tks for your advice.

    There are 3 different paths;

    1)
    As User
    bash-3.00$ echo $PATH
    Code:
    /usr/local/bin&#58;/bin&#58;/usr/bin&#58;/usr/X11R6/bin
    2)
    As "su"
    bash-3.00$ su
    Password:
    root@localhost:/home/satimis# echo $PATH
    Code:
    /usr/gnu/bin&#58;/usr/local/bin&#58;/bin&#58;/usr/bin&#58;.
    3)
    As "su -"
    Password:
    root@localhost:~# echo $PATH
    Code:
    /usr/local/sbin&#58;/usr/local/bin&#58;/bin&#58;/usr/bin&#58;/sbin&#58;/usr/sbin&#58;/usr/X11R6/bin
    Which of them is the correct path? TIA

    BR
    satimis

  7. #7
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    There is no such a thing as correct path. The correct is the one, when all your programs work fine. So I can't say which one is correct for your If you are not sure what to include in your PATH, use as much values as you can Unused paths will not do any harm, so I would reccommend you just add you desired path values to existing PATH. Like this:
    Code:
    export PATH=$PATH&#58;/qqq/www/eee
    add this line in /yourhomedir/.bashrc file or in /root/.bashrc.

  8. #8
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787
    Hi RustamB

    Code:
    export PATH=$PATH&#58;/qqq/www/eee
    add this line in /yourhomedir/.bashrc file or in /root/.bashrc.
    root@localhost:/home/satimis# cat /home/satimis/.bashrc
    Code:
    cat&#58; /home/satimis/.bashrc&#58; No such file or directory
    root@localhost:/home/satimis# locate bashrc
    Code:
    /root/.bashrc
    /home/satimis/./bashrc seems not existing. But bash-3.00$ echo $PATH
    Code:
    /usr/local/bin&#58;/bin&#58;/usr/bin&#58;/usr/X11R6/bin
    has output.

    What shall i do, creating a new empty file? OR copy /root/.bashrc to there?

    root@localhost:/home/satimis# cat /root/.bashrc
    Code:
    # Begin ~/.bashrc
    # Written for Beyond Linux From Scratch
    # by James Robertson <jameswrobertson@earthlink.net>
    
    # Personal aliases and functions.
    
    # Personal environment variables and startup programs should go in
    # ~/.bash_profile.  System wide environment variables and startup
    # programs are in /etc/profile.  System wide aliases and functions are
    # in /etc/bashrc.
    
    if &#91; -f "/etc/bashrc" &#93; ; then
            source /etc/bashrc
    fi
    
    # End ~/.bashrc
    Shall I add the line immediately above "End ~/.bashrc"

    BR
    satimis

  9. #9
    Linux Newbie
    Join Date
    Aug 2005
    Posts
    214
    Create new file ".bashrc" in your home dir and add that command line there.

  10. #10
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,787
    Quote Originally Posted by RustamB
    Create new file ".bashrc" in your home dir and add that command line there.
    So the file contains only one line?

    Tks

    BR
    satimis

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •