Setting default $PATH

enclair wifienclair at gmail.com
Sat Mar 17 15:43:39 UTC 2012


I forgot to CC the list when I wrote these messages:

First message:

I found something weird and I wonder if I should report a bug in the setup
> package or not.
> I've created /etc/profile.d/custom.sh, where I redefine PATH in order to
> have /usr/local after /usr for all users.
> But the files in /etc/profile.d/ are executed twice (in /etc/bashrc and
> /etc/profile), and if a user sets PATH to PATH=$PATH:$HOME/bin, it won't be
> taken into account.
>
> Here is what happens when I start my KDE session + open Konsole:
>
> /etc/profile is called by login
> /etc/profile.d/custom.sh is called by /etc/profile
> ~/.bash_profile is called
> /etc/profile.d/custom.sh is called (by ~/.bashrc which calls /etc/bashrc)
>
> As a result, the user will have the PATH I've defined in custom.sh, but he
> can't append something to it.
>

Second message:

I've added a test at the beginning of /etc/profile.d/custom.sh so that it
> is executed only once:
>
> if shopt -q login_shell ; then
>     unset PATH
>
>     if [ "$EUID" = "0" ]; then
>         PATH=/sbin:/bin:/usr/sbin:/
> usr/bin:/usr/local/sbin:/usr/local/bin
>     else
>
> PATH=/usr/bin:/bin:/usr/games:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
>     fi
>
>     export PATH
> fi
>
> That's way I don't need to change anything user side.
> But it's a bit ugly and I don't think others distributions have this
> problem.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/users/attachments/20120317/4ccc296e/attachment.html>


More information about the users mailing list