6 thoughts on “Ubuntu: Renaming user account

  1. Berni

    Hi, thank you for that useful and nice article.

    Can you give me a hint how to acomplish a solution to the following situatio: I had a UBUNTU 8.04 and updated and updated until 11.04 and at the end i did a repairinstallation to 12.04 because it would not install 12.04 without errors.

    But while doing the repairinstallation to 12.04 i gave a different username instead the old one. Now i have the /home/olduser and the /home/newuser files.

    Is it possible to change the system in that way that it will treat my /home/olduser as the one and only user without deleting my files. I have backed them up so if somethings goes wrong it not a big problem.

    At this stage i added a new user (olduser) and it took a while but ended with an error. After a reeboot the recently added new olduser was created.

    What should i do net to make it happen?

    1. Marko Author

      Hello. When you create user it automatically uses directory from your /home with your user name if this directory has correct ownership. You just need to change owner for your /home/olduser directory to this newly created user (olduser you call it) like this “sudo chown -R olduser /home/olduser” and log in with “olduser” name. After you login you can delete new user account using GUI tools and it will ask you do you wan’t to delete /home/newuser. Good luck!

      1. Berni

        Hi Marko, at this moment my recenty added “OLDUSER” is deactivated. Should i activate it first before changing the rights? How do i change the rights exactly…. ??
        Start a live system and do it with a console or just login as the “wrongnewuser” and do it with your command i a console??? thx & greets

        1. Marko Author

          I do this very often, usually after distro hopping or similar and I do it this way: Just log out of your desktop environment and when on login screen press Ctrl+Alt+F2 to go to virtual terminal. There you login with wrong user, and:

          sudo chown -R olduser /home/olduser

          Then you type exit to log out of wrong user and log in as “olduser”. If everything went right you’ll find your self on your old desktop with your good old /home/olduser home. Then just use GUI tools or command line to delete that wrong user including that /home/wronguser directory and be on your way. Once you removed that wrong user if you can manually remove its home directory like this (this is irreversible!):

          sudo rm -fR /home/wronguser

          The -f means force and -R means recursion into directories of /home/wronguser when removing. By the way any command has its man (user manual) page accessible with “man command” for more info. You exit man pages by pressing q on your keyboard.

  2. Aleksandar

    Hi Marko, great post!

    This command is great for updating all files which contains old users home directory:

    find /home/newuser -type f -readable -writable -exec sed -i "s|home/olduser|home/newuser|g" {} \;

    Easiest solution 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *