$HOME
preserved, based on the idea that they would might have to be able to access .Xauthority
or .ICEauthority
in the home directory of the user running the X session. $HOME
preserved, based on the idea that they would might have to be able to access .Xauthority
or .ICEauthority
in the home directory of the user running the X session. $HOME
is preserved. In any case, I don't have any reason to think this view influenced any decisions made by Ubuntu developers at any point. But I've heard it expressed in some old forum posts. For years, Ubuntu has [shipped a patched version of `sudo` that preserves `$HOME` by default][1]. Besides Ubuntu and its derivatives, [very few other operating systems (perhaps no others) do this][2]. It has been [**decided that this causes more problems than it solves**][3], and [starting in Ubuntu 19.10][4], `$HOME` is no longer one of the few environment variables `sudo` preserves.
In terms of *what* the change is and how it affects users, the key points are:
- **As of Ubuntu 19.10, <code>sudo *command*</code> does what <code>sudo -H *command*</code> does in previous releases.** It can…
env_reset
anyway? It is reasonable for me not to cover that except in the history section? /etc/sudoers
in Debian and Ubuntu has an explicit Defaults env_reset
line, but arguably it has the advantage that it makes it easier to know how to turn off that behavior, by adding a !
before env_reset
. sudo
's configuration are best made in files added to /etc/sudoers.d/
, which having an explicit Defaults env_reset
in /etc/sudoers
somewhat discourages (by encouraging modifying that line). sudoers
files. ubuntu@eoan:~$ sudo cat /etc/sudoers.d/keep-home Defaults env_keep+="HOME" ubuntu@eoan:~$ sudo printenv HOME /home/ubuntu ubuntu@eoan:~$ sudo SUDO_EDITOR='sed -i 1s/^/#/' visudo -f /etc/sudoers.d/keep-home ubuntu@eoan:~$ sudo cat /etc/sudoers.d/keep-home #Defaults env_keep+="HOME" ubuntu@eoan:~$ sudo printenv HOME /root
#
, because that would be the end of the code argument to sed
. sudo sed -i
can be used directly to edit a sudoers
file, but like with sudo vim
, it's not a good idea because there's no syntax checking. ubuntu@eoan:~$ sudo SUDO_EDITOR='sed -i 1s/^/?/' visudo -f /etc/sudoers.d/keep-home >>> /etc/sudoers.d/keep-home: syntax error near line 1 <<< What now? q Options are: (e)dit sudoers file again e(x)it without saving changes to sudoers file (Q)uit and save changes to sudoers file (DANGER!) What now? x