jeudi 1 janvier 2015

sudo as another user with their environment



$ whoami
admin
$ sudo -S -u otheruser whoami
otheruser
$ sudo -S -u otheruser /bin/bash -l -c "echo $HOME"
/home/admin


Why isn't $HOME being set to /home/otheruser even though bash is invoked as a login shell?


Specifically, /home/otheruser/.bashrc isn't being sourced.



Aucun commentaire:

Enregistrer un commentaire