In our network, all user and group IDs are distributed through NIS from a central server and each user's
$HOME directory is on a mounted folder which lives on that central server.
Obviously the user has a different GID from
root and so
root doesn't have access to the mounted
$HOME folder, making it difficult (if not impossible) for the user to run something like
sudo apt update as this needs access to
$HOME as seen by
My question is, can I have a machine-local
$HOME for the files & folders that
sudo needs access to while the
$HOME for my other (non-
sudo) work keeps pointing to the mounted folder?
[user@machine ~]$ id uid=544(user) gid=40(src) groups=40(src),101(systemd-journal) [user@machine ~]$ sudo id uid=0(root) gid=0(root) groups=0(root),40(src),101(systemd-journal),600(visitors),13010(hlcc),19016(identhw),51107(cadadm) [user@machine ~]$ sh -c 'echo $HOME' /net/server/home/user [user@machine ~]$ sudo sh -c 'echo $HOME' /net/server/home/user
How can I change the result of the last line (i.e. the
sudo version of
$HOME) point to a local folder on
machine instead of the mounted network path?
Thanks for the answers. Turns out my question was almost identical to this one on unix.stackexchange.com.
I also found out that the problem I had with
apt-get update wasn't actually related to the
HOME environment variable, instead it was related to the fact that I was calling
sudo apt-get update from my (
user's) home folder, similar to this question which can be solved by simply calling
sudo apt-get update from another folder, e.g.
But since my question here was more about the
HOME seen by
sudo, I accepted techraf's answer because it doesn't require any additional switches or definitions in the
sudo command line.