How to rename a user safely?

13,276

Solution 1

Safely? Don't rename at all. Instead, (make sure the user is logged out first) create a new user with the correct username, rename the old home directory to the new username and chown -R the folder to the new user.

This assumes that you're not using encrypted homes. That would require some different steps, but since I haven't done that myself, I'll leave that to someone else.

Solution 2

Use usermod like so:

usermod -l newname currentname
Share:
13,276

Related videos on Youtube

Ivan
Author by

Ivan

Updated on September 18, 2022

Comments

  • Ivan
    Ivan over 1 year

    I've misspelled user name when installing Ubuntu and would like to rename if possible. How can I safely change my user name?

    • Takkat
      Takkat over 12 years
      This answers may still be valid.
    • Ivan
      Ivan over 12 years
      @takkat thanks. There you've got a good formal answer on how to rename a user. But I believe Jo-Erlend's suggestion I've got here is safer :-)
    • Takkat
      Takkat over 12 years
      If you haven't done much with your user, I'd definitely go for Jo-Erlends approach. I had other people in mind that may come here for a more sophisticated solution on this topic. Renaming users is not a trivial task.