From
http://wiki.debian.org/sudo:
Wrong HOME (and profile settings) behavior
If you are having problems when you sudo to your shell and your $HOME (and profile settings) doesn't work as expected because your new HOME is /root, you need to know that the default sudo configuration in Squeeze resets all environmental variables. To restore the old behavior of preserving the user's $HOME environment variable you can add this to your /etc/sudoers configuration file:
Defaults env_keep += HOME
Then the precaution given by
the manual, where running sudo
leads to running a root application with a users configuration, which may override or change permissions.
is inaccurate, at least in the Debian context.
I request that the manual be updated accordingly to clarify that sudo's default behavior in Debian is not such as that of sudo in Ubuntu,
https://help.ubuntu.com/community/RootSudo#Graphical_sudo, where:
Graphical sudo
You should never use normal sudo to start graphical applications as Root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by Root.
Case in point:
Run the following in a terminal, using default su and sudo settings:
# sudo-1.8.5p2-1 in Debian sid
johndoe@debian:~$ sudo env # johndoe is member of sudo group
USER=root
HOME=/root
SUDO_COMMAND=/usr/bin/env
SUDO_USER=johndoe
SUDO_UID=1000
SUDO_GID=1000
# sudo-1.8.3p1-1ubuntu3 in Xubuntu 12.04
johndoe@ubuntu:~$ sudo env
HOME=/home/johndoe
USER=root
SUDO_COMMAND=/usr/bin/env
SUDO_USER=johndoe
SUDO_UID=1000
SUDO_GID=1000
As can be seen from above, replacing env with any other command, the running environment sudo in Debian sets is HOME=/root and not HOME=/home/johndoe, unless "Defaults env_reset += HOME" in /etc/sudoers is used. This is very much different from the sudo in Ubuntu, which requires using gksudo to properly set HOME=/root, which prevents sudo from messing with the user's profile and/or configuration permissions.