SUDO resets path and environment variables

Sudo resets PATH, along with many other environment variables, for security reasons. It doesn’t matter what is set in /etc/profile, unless you run sudo -i.

The sudo manual page, under SECURITY NOTES, gives an insight about the security implications, along with the options you have to fiddle in your /etc/sudoers file to modify these restrictions, after you understand the implications of doing so.

You can always do:

sudo env "PATH=$PATH" godi_console

or even:

sudo "PATH=$PATH" godi_console

as sudo does treat leading arguments containing = characters as environment variable assignments by itself as well.

As a security measure on Debian, /etc/sudoers has the secure_path option set to a safe value.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.