8

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

0

1 Answer 1

12

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:

username:password:uid:gid:additional_info:home:shell

So, for example, you'll find:

root:x:0:0::/root:/bin/bash

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.

3
  • 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. 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
    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. Oct 30, 2012 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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