Can not keep the environment parameters when use “sudo xxxx”
sudo problem: can not keep the environment parameters when use “sudo xxxx”
For example:
“sudo doesn’t set HOME”
Solutions:
1. set the related environment in the file /etc/environment or /etc/bashrc or /etc/profile , this maybe work, but I did not try.
2. the command “sudo” from version 1.6.8p7-1.3 to 1.7.0 have the problem of the environment parameters, so maybe you can update the “sudo” to 1.7.0 or later
3. setting in the /etc/sudoers to keep the environment parameters when use “sudo”
if you do not want to keep the parameters, add following line to the /etc/sudoers:
Defaults env_reset
if you want to keep the parameters, add the following lines, pay attention to the environments, add what you want/delete what you do not want:
Defaults env_keep = “COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY”
4. How to check the environment parameters are kept or not:
env >> currentenv
sudo env >> sudoenv
diff currentenv sudoenv
References:
http://linux.derkeiler.com/Mailing-Lists/Debian/2006-03/msg00537.html
http://linux.derkeiler.com/Mailing-Lists/Debian/2006-03/msg00498.html
http://ubuntuforums.org/archive/index.php/t-930500.html
http://blenderartists.org/forum/showthread?t=7412
http://lists.zenoss.org/pipermail/zenoss-users/2006/000439.html
http://www.gratisoft.us/pipermail/sudo-users/2005-August/002593.html
http://www.gratisoft.us/pipermail/sudo-users/2008-September/003734.html
http://mail.python.org/pipermail/python-list/2006-April/379061.html
http://www.unix.com/unix-advanced-expert-users/97743-sudo-environment-setting.html
https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/31690
http://ubuntuforums.org/showthread.php?t=956777
https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/192651
[…] Can not keep the environment parameters when use "sudo xxxx" […]
Baby name meaning and origin for Damisi
June 25, 2009
Cool!
flash
July 7, 2009