0

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?

1
  • 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, 2013 at 20:45

1 Answer 1

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.

3
  • 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 Ward
    Apr 19, 2013 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, 2013 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 Ward
    Apr 19, 2013 at 18:29

You must log in to answer this question.

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