Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

migrated from stackoverflow.com Oct 30 '12 at 23:38

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 4 down vote accepted

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:

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 and change the home directory.

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

share|improve this answer
3  
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
2  
@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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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