Ubuntu – How to restore/add previous user account


I've recently fixed a broken installation by reinstalling Ubuntu with a new username, and thankfully my old account survived (yay). Now I'd like to add my old account back to Ubuntu. Note that I'm not necessarily trying to overwrite the new user account. I just want to restore the old account and have it be the default when I boot up Ubuntu.

Edit I can create a new account under the old name but I'm worried that that will destroy the old account data.


I've replaced the my new home folder with my old home folder but that didn't work.

Best Answer

#1 Back up your data!
#2 Add the user with the exact same username as before.
#3 You should have all your settings and files back.

Alternative for geeks:

#1 Backup Backup Backup your data!
#2 Add this line to then end of /etc/passwd (replace [username] with your username, replace 1700 with your previous userid, and replace 1701 with your previous groupid - if you don't know your userid and groupid, then set both to 1700):


Try logging into the console (CTRL-ALT-F1) as [username] with no password. Then run passwd and enter a new password. You should then be able to log in as before.

If you can't find your old userid and groupid, then you'll likely have some file permissions problems, and you'll need to log in as another user and run this command

 sudo chown -R [username]:[username] /home/[username]

to restore permissions.