My home folder (~ and $HOME) points to /home/user , how do I change this directory?

I tried


But this only works until I start a new shell.

I also tried looking for definitions in /etc/environment, ~/.profile, and /etc/profile.d/ but I didn't find HOME defined anywhere.

I also looked here, but I'm not interested in moving it to a separate partition, I merely would like to change the directory it points to.

2 Answers 2


HOME is usually derived from the user's entry in /etc/passwd. You can use usermod to change this entry, but only if your user is not logged in. Therefore, you need to either:

  1. Set a root password and login as root from a TTY, or
  2. Boot to recovery mode (see How do I reset a lost administrative password? for an example guide)

In either case, once you have a root shell, do:

usermod --move-home --home /path/to/new/home your-username
chown your-username:$(id -gn your-username) /path/to/new/home -R

This should move your home directory to the new location and ensure correct ownership (which the usermod command should do, the chown is just in case). Now logout/reboot and login as your user.


To just change the home dir for the user USER to /some/other/dir use

sudo usermod --home /some/other/dir USER

You need to make sure /some/other/dir actually exists and has proper permissions. No files will be copied.

If you want to move the contents of the old home dir to the new one you can use.

sudo usermod --move-home --home /some/other/dir USER

Replace /some/other/dir with the path of the new home folder. If it doesn't exist yet it will be created. The content of the old $HOME will be moved to the new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.