sudo
by default uses a minimal PATH
, to make it safe for use by the root user. That is not necessarily the same as the PATH
you would get by logging in as the root user, or by doing
sudo su -
For instance, in newer Red Hat releases, I've noticed that the path omits /usr/local/bin
.
The manual page summarizes this in a section entitled Security Notes:
sudo tries to be safe when executing external commands.
There are two distinct ways to deal with environment variables. By default, the env_reset
sudoers
option is enabled. This causes commands to be executed with a minimal environment containing TERM
,
PATH
, HOME
, SHELL
, LOGNAME
, USER
and USERNAME
in addition to variables from the invoking process
permitted by the env_check
and env_keep
sudoers options. There is effectively a whitelist for
environment variables.
Further reading:
sudo
. see http://man7.org/linux/man-pages/dir_section_1.html and http://man7.org/linux/man-pages/dir_section_8.html – Tim Jul 06 '16 at 12:05PATH
used bysudo
? 2. Is it correct that itsPATH
is not used by any other user includingroot
?