sudo and PATH?

Derek Broughton news at
Mon Jan 8 19:44:19 UTC 2007

Martin Marcher wrote:

> Am 08.01.2007 um 15:08 schrieb Derek Broughton:
>> Martin Marcher wrote:
>>> Hello,
>>> Am 05.01.2007 um 20:01 schrieb Matt Price:
>>>> but this of course doesn't extend over to sudo  Is there a way to
>>>> change
>>>> sudo's path, preferably permanently and for every user?
>>> have a look a man sudoers(5) and search for "env_reset" and
>>> "env_keep" and also the "env_" options in general.
> Quote:
>         env_reset   If set, sudo will reset the environment to only
> contain the
> Defaults env_keep = "PATH" # keeps $PATH for all users
> Defaults:YourUserName env_keep = "HOME USER PATH" # keeps HOME USER
> PATH for YourUserName

I'm sorry, I'm too dense for that.  What value of PATH is being "kept"?  I
_think_ it means (and experiment seems to bear it out) that if "derek"
executes "sudo XYZ" then XYZ is run with "derek"'s PATH, but if that's the
default case, I'm not sure why the OP had a problem.

>>> And please do use "visudo" to edit the file...
>> One of those really stupid legacy unixisms.  For years I _didn't_
>> use visudo (without problems) because I refuse to use vi.  Then I
>> realized it doesn't really use vi (unless that's your default editor).
> hehe, I wasn't refering to using vi vim emacs or any editor but more
> to that if you break your sudoers file without using visudo you won't
> be able to use any sudo command 

Yes, I know.  However, I suspect there are other uses like me who were
scared off by the "vi".  So in essence, I was agreeing that you _should_
use visudo, and don't be frightened by the name.

More information about the ubuntu-users mailing list