Title says it all, how do I change the home directory of the 'root' user in Ubuntu 12.04?


Here are the instruction, but be sure to know what you're doing.

On every *nix system you'll find a file called /etc/passwd which lists all users and some settings. Here is the syntax of that file:


So, for example, you'll find:


Which means the user is called root, the password is hidden (it's on /etc/shadow), uid is 0, gid is 0, no additional info, the home directory is /root and the default shell is /bin/bash.

Edit that file and change the home directory.

However, I don't see any reason to do it.

  • 5
    You should probably use the vipw command to edit the passwd file. It sets locks to avoid file corruption. Messing up /etc/passwd can easily hose your system. – Keith Thompson Oct 30 '12 at 22:16
  • Thanks that will work. Just for general information, I need to change the home directory for a VPS template - it's just an ease of use thing – user1710563 Oct 30 '12 at 22:21
  • 3
    @user1710563: It might be helpful to update your question to explain why you need to do this. The general reaction (mine included) has been "Don't do that"; if you tell us why you want to do this, you're likely to get better information -- including possible alternatives that don't require changing root's home directory. – Keith Thompson Oct 30 '12 at 22:37

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.