I don't understand where sudo finds the value for the PATH env variable.
Here is the output of the relevant (at least I thought they were)
commands. Can somebody explain to me why I still have
/usr/local/texlive/*2011*/bin/i386-linux in the first sudo output ? I
don't get it, and did not find anything in the man page of sudo.
Nicolas Richard <theonewiththeevillook@yahoo.fr> wrote:
>Hi everybody,
>
>I don't understand where sudo finds the value for the PATH env
>variable.
>
>Here is the output of the relevant (at least I thought they were)
>commands. Can somebody explain to me why I still have
>/usr/local/texlive/*2011*/bin/i386-linux in the first sudo output ? I
>don't get it, and did not find anything in the man page of sudo.
>
>Thanks in advance for your help.
>
>youngfrog@geodiff-mac3 ~ $ bash -c 'echo $PATH'
>~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin
>
>youngfrog@geodiff-mac3 ~ $ source /etc/profile
>
>youngfrog@geodiff-mac3 ~ $ bash -c 'echo $PATH'
>/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux
>
>youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH'
>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux
>
>youngfrog@geodiff-mac3 ~ $ sudo -i bash -c 'echo $PATH'
>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux:/root/bin
>
>youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 /etc
>
>youngfrog@geodiff-mac3 ~ $ sudo grep -r texlive/2011 ~root
>/root/.bash_history:cd /usr/local/texlive/2011
>/root/.bash_history:grep texlive/2011 * -r
>/root/.bash_history:grep texlive/2011 . -r
>/root/.bash_history:grep texlive/2011 .* -r
>
>youngfrog@geodiff-mac3 ~ $ grep -v '^#|^$' /etc/environment
>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin
Nicolas.
I can see several /usr/local/... paths in your /etc/environment.
--
Joost
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Joost> Nicolas Richard <theonewiththeevillook@yahoo.fr> wrote:
>> Here is the output of the relevant (at least I thought they were)
>> commands. Can somebody explain to me why I still have
>> /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output
Joost> I can see several /usr/local/... paths in your
Joost> /etc/environment.
Hello Joost,
Yes, I see them too, but they are pointing to the more recent 2012
release of texlive, not the older 2011 one. What I don't understand is
where /sudo/ finds the environment when called without the "-i" option
(and in particular, that entry for texlive 2011). The manpage seems to
say that it simply uses the current environment (quoting the manpage :
"Note, however, that the actual PATH environment variable is not
modified and is passed unchanged to the program that sudo executes.")
but that does not seem right.
--
N.
10-10-2012, 09:49 AM
"J. Roeleveld"
Where does sudo get the PATH ?
On Tue, October 9, 2012 5:03 pm, Nicolas Richard wrote:
>>>>>> "Joost" == J Roeleveld <joost@antarean.org> writes:
>
> Joost> Nicolas Richard <theonewiththeevillook@yahoo.fr> wrote:
> >> Here is the output of the relevant (at least I thought they were)
> >> commands. Can somebody explain to me why I still have
> >> /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output
>
> >> youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH'
> >> /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux
>
> >> youngfrog@geodiff-mac3 ~ $ grep -v '^#|^$' /etc/environment
> >> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin
>
> Joost> I can see several /usr/local/... paths in your
> Joost> /etc/environment.
>
>
> Hello Joost,
>
> Yes, I see them too, but they are pointing to the more recent 2012
> release of texlive, not the older 2011 one. What I don't understand is
> where /sudo/ finds the environment when called without the "-i" option
> (and in particular, that entry for texlive 2011). The manpage seems to
> say that it simply uses the current environment (quoting the manpage :
> "Note, however, that the actual PATH environment variable is not
> modified and is passed unchanged to the program that sudo executes.")
> but that does not seem right.
>
> --
> N.
What do you get with "echo $PATH" when not using sudo?
--
Joost
10-10-2012, 09:50 AM
"J. Roeleveld"
Where does sudo get the PATH ?
On Tue, October 9, 2012 5:03 pm, Nicolas Richard wrote:
>>>>>> "Joost" == J Roeleveld <joost@antarean.org> writes:
>
> Joost> Nicolas Richard <theonewiththeevillook@yahoo.fr> wrote:
> >> Here is the output of the relevant (at least I thought they were)
> >> commands. Can somebody explain to me why I still have
> >> /usr/local/texlive/*2011*/bin/i386-linux in the first sudo output
>
> >> youngfrog@geodiff-mac3 ~ $ sudo bash -c 'echo $PATH'
> >> /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/local/texlive/2011/bin/i386-linux
>
> >> youngfrog@geodiff-mac3 ~ $ grep -v '^#|^$' /etc/environment
> >> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.3:/usr/local/texlive/2012/bin/i386-linux:/root/bin
>
> Joost> I can see several /usr/local/... paths in your
> Joost> /etc/environment.
>
>
> Hello Joost,
>
> Yes, I see them too, but they are pointing to the more recent 2012
> release of texlive, not the older 2011 one. What I don't understand is
> where /sudo/ finds the environment when called without the "-i" option
> (and in particular, that entry for texlive 2011). The manpage seems to
> say that it simply uses the current environment (quoting the manpage :
> "Note, however, that the actual PATH environment variable is not
> modified and is passed unchanged to the program that sudo executes.")
> but that does not seem right.
And, what is in the .bash_profile and .bashrc files in your homedir and in
root's homedir?
--
Joost
10-10-2012, 02:57 PM
"Nicolas Richard"
Where does sudo get the PATH ?
>>>>> "Joost" == J Roeleveld <joost@antarean.org> writes:
Joost> And, what is in the .bash_profile and .bashrc files in your
Joost> homedir and in root's homedir?
In my homedir:
.bash_profile loads .bashrc
.bashrc says export PATH="~/bin/overrideglobal:${PATH}:~/bin" (and
defines some aliases)
In root's: I have no such files.
Maybe it would be less distracting if I don't use a shell at all :
Joost> What do you get with "echo $PATH" when not using sudo?
You mean, when I'm logged in as root ? Then it's the same as when using
sudo -i.
N.
10-10-2012, 06:43 PM
Joost Roeleveld
Where does sudo get the PATH ?
On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote:
> >>>>> "Joost" == J Roeleveld <joost@antarean.org> writes:
> Joost> And, what is in the .bash_profile and .bashrc files in your
> Joost> homedir and in root's homedir?
>
> In my homedir:
> .bash_profile loads .bashrc
> .bashrc says export PATH="~/bin/overrideglobal:${PATH}:~/bin" (and
> defines some aliases)
Does it load any global default?
> In root's: I have no such files.
>
> Maybe it would be less distracting if I don't use a shell at all :
>
> youngfrog@geodiff-mac3 ~ $ sudo -i env | grep ^PATH
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/
> usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/local/texlive/2012/bin/i386-linux:/
> root/bin
>
> youngfrog@geodiff-mac3 ~ $ sudo env | grep ^PATH
> PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/
> usr/local/texlive/2011/bin/i386-linux
>
>
> Joost> What do you get with "echo $PATH" when not using sudo?
>
> You mean, when I'm logged in as root ? Then it's the same as when using
> sudo -i.
No, when you're logged in as your normal user.
In other words, what is in the environment when you are normally logged in?
--
Joost
10-11-2012, 02:25 PM
"Nicolas Richard"
Where does sudo get the PATH ?
Joost Roeleveld <joost@antarean.org> writes:
> On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote:
>> In my homedir:
>> .bash_profile loads .bashrc
>> .bashrc says export PATH="~/bin/overrideglobal:${PATH}:~/bin" (and
>> defines some aliases)
>
> Does it load any global default?
No. Here are the full files, omitting comments and empty lines :
and I forgot to mention that it was the same as :
youngfrog@geodiff-mac3 ~ $ env | grep ^PATH
PATH=~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin
and yet the same as :
youngfrog@geodiff-mac3 ~ $ echo $PATH
~/bin/overrideglobal:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.5.4:/usr/games/bin:/usr/local/texlive/2012/bin/i386-linux:~/bin
Thanks for trying btw. I certainly did something really stupid to set
the path the first time, but can't see where.
N.
10-11-2012, 04:24 PM
Pandu Poluan
Where does sudo get the PATH ?
On Oct 11, 2012 9:29 PM, "Nicolas Richard" <theonewiththeevillook@yahoo.fr> wrote:
>
> Joost Roeleveld <joost@antarean.org> writes:
> > On Wednesday, October 10, 2012 04:57:50 PM Nicolas Richard wrote: