FedoraForum.org - Fedora Support Forums and Community
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2016
    Location
    france
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [SOLVED] where is the PATH built these days?

    Hi all,

    this is my first post on this forum so hi to all.

    I've been using linux for a while now but I'm a new to systemd and I suspect the answer to my question will be systemd!

    My $PATH puts "/usr/local/bin" before "/usr/bin". I'd lilke to change the order or just remove something from the default PATH but I can not figure out where the PATH is built.

    I cannot find it in /etc/profile, /etc/bashrc, ... so I'm guessing it's in systemd.

    How can I achieve this?

    Any help is welcome!
    Last edited by foobar2devnull; 23rd May 2016 at 02:27 PM. Reason: mark as solved

  2. #2
    Join Date
    Jan 2010
    Posts
    8,687
    Mentioned
    41 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    You can change the order of your path in .bashrc (interactive) or .bash_profile (as you log in.)

    You can change the order of your path in .bashrc (interactive) or .bash_profile (as you log in.)

    Depending upon what you want to remove and for how many users, you can do it for a user in their .bash_profile or .bashrc file. There's also some pathmunge lines in /etc/profile. (If, for example, you want to remove sbin files from a normal user's path.) http://unix.stackexchange.com/questi...s-even-in-cron indicates that you can use /etc/environment.

  3. #3
    Join Date
    May 2016
    Location
    france
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Hi,

    Thanks for your answer. I'll give your solution a go. My question in the end is "how is the base path created?".

    Is it generated from an init script?

  4. #4
    Join Date
    Apr 2016
    Location
    Malaysia
    Age
    30
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    I think PATH is made by /etc/profile
    https://github,com/truboxl

  5. #5
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Depends on your distribution...

    I think most are using /etc/profile.d to set the defaults for the various shells. Each file there sets a profile for a different application (usually a shell being used in different ways).

    After that the /etc/profile.d there is the system wide "/etc/profile" file that modifies the results...

    Then it depends on how the shell is being invoked. There is .bashrc that each user uses when starting the bash shell, .cshrc for csh (and others). Then there are other startups - for the bash shell ".bash_profile, .bash_login, and .profile (all in the users home directory). If it is not a login shell then some get skipped in favor of using .bashrc only...

    Lots of places... Some depend on the GUI being used as the startup script for the GUI makes changes...

  6. #6
    Join Date
    Jun 2005
    Location
    Montreal, Québec, Canada
    Age
    85
    Posts
    10,166
    Mentioned
    33 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Hi foobar2devnull

    My path statement

    /usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/leslie/.local/bin:/home/leslie/bin

    Here is a question for you, « if you can please respond as to why you want to change the order of the path statement.
    .
    If you are creating local software versions, would you not want your versions to be retrieved from /usr/local....
    before the one with the same name within /bin or /usr/bin , the system version.? »

    With Fedora /bin and /usr/bin point to a common directory. As of Fedora 23, a decision was made to merge them into one /usr/bin partition and to use symbolic links for /usr/bin

    Ditto for /sbin and /usr/sbin.

    La vie Fedora n'est pas toujours bizzare, mais bien pensée.
    Leslie in Montreal

    Interesting web sites list
    http://forums.fedoraforum.org/showth...40#post1697840
    We get too soon old, and too late smart!

  7. #7
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    4,042
    Mentioned
    20 Post(s)
    Tagged
    1 Thread(s)

    Re: where is the PATH built these days?

    I was looking at my PATH and I am in agreement with the OP - it is not clear where the initial values are being set.

    My PATH in a terminal is
    Code:
    /usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/brenton/.local/bin:/home/brenton/bin
    If I strip off the stuff added in my .bashrc I get
    Code:
    /usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
    If I then strip off the stuff added from /etc/profile.d I get
    Code:
    /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
    Prior to running the scripts in /etc/profile.d the /etc/profile script attempts to add /usr/local/sbin and /usr/sbin at the end if they are not already in the path. Since they are not the last two, I can conclude that the above core PATH was already set when /etc/profile was run.

    This implies that either systemd or the login process has set the PATH.

    I have many ideas, even some I haven't thought of yet.

  8. #8
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    15,336
    Mentioned
    186 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Quote Originally Posted by ocratato
    ... Since they are not the last two, I can conclude that the above core PATH was already set when /etc/profile was run.
    This implies that either systemd or the login process has set the PATH.
    login does it:

    This is from a middle section of the 'man login' page

    The user and group ID will be set according to their values in the /etc/passwd file. There is one exception if the user ID is zero: in this case, only the
    primary group ID of the account is set. This should allow the system administrator to login even in case of network problems. The value for $HOME, $USER,
    $SHELL, $PATH, $LOGNAME, and $MAIL are set according to the appropriate fields in the password entry. $PATH defaults to /usr/local/bin:/bin:/usr/bin for normal users, and to /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin for root, if not otherwise configured.

  9. #9
    Join Date
    May 2016
    Location
    france
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Sorry for my prolonged absence, we had a crisis to resolve.

    @marko, well spotted, thanks! I'll check it out as soon as I've finished replying. Thanks!

    @ocratato, thanks for the reverse engineering

    @Isatenstein, I don't like having "/usr/local/bin" in front of /usr/bin, ... I am no security expert but if someone on the same box created a malicious program that he calls "ls", I will run it without even knowing it... I would not mind ~/bin though...

    @jpollard, why complicate something that worked well and was easy? Same goes for network setup these days... I got a lot of info so I'll dig further. Thanks for your help.

    @TurboXL, not that easy it seems...

    Thank you all for your feedback.

  10. #10
    Join Date
    May 2016
    Location
    france
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    My original path was:

    Code:
    /usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:...
    What I want is:

    Code:
    /bin:/usr/bin:/usr/local/bin:/usr/local/sbin:...
    What I managed to get up to now was:

    Code:
    /usr/lib64/qt-3.3/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    I managed to remove (temporarily, for test reasons) /usr/local/bin to see it it worked and it did.

    To do this, i added a line at the end of /etc/login.defs:

    Code:
    ENV_PATH PATH=/bin:/usr/bin
    How qt manages to jump the queue is the next one on the list...

    @marko, thanks for pointing me in the right direction

  11. #11
    Join Date
    May 2016
    Location
    france
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: where is the PATH built these days?

    Ok, problem solved

    My initial PATH
    /usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/jdoe/.local/bin:/home/jdoe/bin

    It can be split into three files

    /etc/profile.d/qt.sh
    Code:
    if ! echo ${PATH} | /bin/grep -q $QTDIR/bin ; then
       PATH=$QTDIR/bin:${PATH}
    fi
    I reversed the order here.

    /etc/login.defs
    Code:
    ENV_PATH PATH=/bin:/usr/bin:/usr/local/bin
    ENV_SUPATH PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
    note that if you do not mention ENV_PATH in the file, the default (as per the man login page) is "/usr/local/bin:/bin:/usr/bin".
    Note too that documentation seems to conflict on default paths between login and login.defs.

    /etc/skel/.bash_profile
    Code:
    PATH=$PATH:$HOME/.local/bin:$HOME/bin
    You might have move options in /etc/profile.d.
    You might also have more options in ~/.bash_profile

    My result:
    Code:
    /bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/lib64/qt-3.3/bin:/home/jdoe/.local/bin:/home/jdoe/bin
    Thank you all for your help.
    Last edited by foobar2devnull; 24th May 2016 at 02:27 PM. Reason: updated info

Similar Threads

  1. So ... what about ATI/AMD these days?
    By Dan in forum Hardware
    Replies: 25
    Last Post: 16th May 2012, 10:07 PM
  2. how to add path /usr/local/bin/lftp to user path
    By nix4me in forum Using Fedora
    Replies: 6
    Last Post: 18th August 2010, 12:31 AM

Tags for this Thread

Posting Permissions

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