I would like to know, whow to modify properly the homedir of a user.
I already know about this command
usermod -d /home/peter peter
But now, do I have to create the homedir before? And what will happen to the old homedir? (I know about the -m option which would move the contents, but I don't want to move/remove the old content).
So for not removing and just leaving the old content, would I just have to use the command, exactly as I mentioned above?
I use Ubuntu 12.04.1 LTS "Server".
whoami
and everybody logged in withwho
. – Warren Hill Feb 04 '13 at 10:21users
and it just returned my own name. Which was not the username, which I assigned the new home directory to. Seems to me the user was somehow assigned to me, because after re-login it worked well. – Peter Feb 04 '13 at 12:38move
old dir to new dir, so it will not create new dir if old dir does not exist. http://manpages.ubuntu.com/manpages/precise/en/man8/usermod.8.html – HVNSweeting Apr 21 '15 at 10:01sudo chown peter: peter
might be preferable here. This form<user>:
uses the user's default group, which is not necessarily the same name as the user name. – Jamie Cockburn May 17 '18 at 18:36/etc/passwd
? Is that unsafe? – Sridhar Sarnobat Mar 21 '21 at 00:14/etc/passwd
withsudo vipw
which will safely lock the file while you're editing it. Next time the user logs in, they will come into their new home directory. – BadHorsie Jul 05 '21 at 16:15