PATH is an environment variable, and therefor it 'defaults' or 'resets' when you change environment. See man sudoers
for an explanation:
env_reset If set, sudo will reset the environment to only contain
the LOGNAME, SHELL, USER, USERNAME and the SUDO_* vari-
ables. Any variables in the caller's environment that
match the env_keep and env_check lists are then added.
The default contents of the env_keep and env_check
lists are displayed when sudo is run by root with the
-V option. If sudo was compiled with the SECURE_PATH
option, its value will be used for the PATH environment
variable. This flag is on by default.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
is the basic path without modifications. Different users will have different directories added to them for several reasons.
And the reasoning should be: root should never ever have more directories in its PATH than needed. Or the other way around: if root needs a file it should be in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
. You do not play games as root. You do not use a desktop manager as root. A root is for admin tasks.
The wiki has some more information (amongst others which files are used to add to PATH): https://help.ubuntu.com/community/EnvironmentVariables
sudo -i
makes it use/etc/environment' too ;) And the last question: check
man sudoers`. There are several options there. But why would you need to change root? There should be no reason for it. – Rinzwind Nov 20 '12 at 10:01sudo -i
command, and after doingsu root
the value of$PATH
returned was same as it was for a normal user,any ideas on that? There should be no reason for it? yes, I want to change it only for learning purpose. – Ashwini Chaudhary Nov 20 '12 at 10:25