Does anyone know how I might change my home directory in the shell please?
3 Answers
Running
sudo usermod -d new_home_dir username
will change your home directory to new_home_dir
and will also update the system file that stores the location of your home directory (/etc/passwd
).
If you also want to move all files from your current home directory, use:
sudo usermod -d new_home_dir -m username
-
After I have done this, only desktop background is shown when I log in. For 13.10 .. even this is an answer from 2009 :)– AleksMay 26, 2014 at 22:31
-
1@Aleks the functionality of
usermod
hasn't changed in years, or probably decades, so this answer should still be valid. As for why you're only seeing your desktop background, perhaps something else in your desktop environment depends on the username, in which caseusermod
doesn't know about it. But I can only guess at why this is happening (without having access to the system).– David ZMay 27, 2014 at 0:29 -
Thanks David. I thought too that this functionality hasn't changed in years so I have tried it. My was a fresh new install of Ubuntu, so , with additional steps, this answer helped me askubuntu.com/a/250877/223469 (just like yours, but with additional step - or more precise to create a new fresh new folder, which in my case was enough for me) thanks David– AleksMay 27, 2014 at 7:22
usermod -d new_home_dir username
You may meet error like "usermod: user is currently used by process xxx", try this:
sudo su
nohup kill xxx; sleep 2; usermod -d new_home_dir username &
Then reconnect via ssh.
/etc/fstab
(5) move old home directory out of the way (6) move new home directory to/home
(7) mount new/home
(8) check everything, and remove old home directory