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


1 Answer 1


Here are the instructions, 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 (I recommend vipw to avoid corruption) and change the home directory.

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

  • 6
    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. Commented Oct 30, 2012 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
    Commented Oct 30, 2012 at 22:21
  • 4
    @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. Commented Oct 30, 2012 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .