I would like to change the location of root's home directory from /root to /var/root. I used to be able to do this with usermod:
usermod -d /var/root root
However, with the latest version of usermod, you cannot change the directory of the currently logged in user. I am trying to change root's home directory at boot time in a system setup script that is run the first time a system is booted, so I can't really be any other user.
Is there another way to change the home directory of the currently logged in user (root in this case)?
I could probably sed /etc/passwd, but that seems sloppy.