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.

I've tried this in the past with zero success. How do I change the /home/USER directory for a user, when I change their username, and how do I update their username without causing massive breakage?

share|improve this question
    
Your question is not clear - "retaining Data structure" would imply to not rename anything, but in the text you state it differently - please clarify. –  guntbert Apr 19 '13 at 20:45

1 Answer 1

If you change only the username (presumably by editing /etc/passwd, /etc/shadow, and /etc/group), then simply doing mv /home/USER /home/NEWUSER as root should be enough, assuming you also changed the directory in /etc/passwd which is used as the home for that user.

If the UID (and or GID) was also changed, you'll need to run chmod -R NEWUSER.NEWGROUP /home/NEWUSER as well.

share|improve this answer
    
I've never gotten username changes to work properly... so basically what you're saying is i edit /etc/passwd, /etc/shadow, and /etc/group to do the username changes... and then move the home directory as root? Wouldn't i have to usermod so that the home directory is recognized in the new path? –  Thomas W. Apr 19 '13 at 18:15
    
How were you doing the username change? You can use usermod to change the home directory path, instead, but if you're already editing /etc/passwd to change the username, it's faster to just edit it there. –  dobey Apr 19 '13 at 18:27
    
dobey, the point of this question in a nutshell was to figure out the correct method of changing the user while retaining data structure. I might've missed a step or two when I tried a while ago, but I'll take another stab with a test user (so as to make sure I don't break my ACTUAL user) –  Thomas W. Apr 19 '13 at 18:29

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.