I expected the -H option to give me the target user's environment.
nbest@geo:~$ sudo -H -u tanum echo $HOME /home/nbest nbest@geo:~$ sudo -u tanum echo $HOME /home/nbest nbest@geo:~$ sudo -i -u tanum echo $HOME /home/nbest nbest@geo:~$ sudo -H -i -u tanum echo $HOME /home/nbest
This would allow me to say:
sudo -u tanum ls ~
and get the target user's home directory listing. Not the case. Is this caused by the env_reset
default in sudoers
?
If so does -H have any effect? What is the safest way to override this behavior?
If not what is the intended effect of -H?
Please set me straight.
sudo do what I mean
– Neil Best Aug 28 '13 at 16:02sudo -H -u buildbot bash -c "echo $HOME"
gives me/home/ubuntu
, which is the default user on some Ubuntu images. – Cerin Sep 06 '17 at 21:54sh -c 'echo $HOME'
– Andrea Corbellini Sep 06 '17 at 23:42-H
is-E
; preserve the calling user's environment – SpinUp __ A Davis Mar 15 '21 at 01:12