How does one change user's home directory in Ubuntu 9.04?

40

17

Does anyone know how I might change my home directory in the shell please?

Daniel Elliott

Posted 2009-09-13T10:49:16.930

Reputation: 511

http://ubuntuforums.org/showthread.php?t=46866 this is a nice How-To on home-dir moving. I Have not tried this myself, but it looks rather complicated. Nick – Nick – 2009-09-13T11:04:03.667

It's not as complicated as it looks, they just had to explain in detail for people who aren't familiar with the process. All it really involves is (1) create partition, if necessary (2) mount partition (3) copy files (3) unmount partition (4) edit /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 – David Z – 2009-09-13T12:33:39.957

Answers

64

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

David Z

Posted 2009-09-13T10:49:16.930

Reputation: 5 688

1Worked for me in Ubuntu 12.04, thanks – HappyDeveloper – 2012-07-04T03:19:41.287

After I have done this, only desktop background is shown when I log in. For 13.10 .. even this is an answer from 2009 :) – Aleks – 2014-05-26T22:31:19.270

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 case usermod doesn't know about it. But I can only guess at why this is happening (without having access to the system). – David Z – 2014-05-27T00:29:53.800

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 http://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

– Aleks – 2014-05-27T07:22:05.327

2

I have not tried this, but I think you can change it in /etc/passwd.

Johan

Posted 2009-09-13T10:49:16.930

Reputation: 4 827