1

I have a problem that "corrupted" my user, let's call it olduser. I got stuck in the login screen and nothing I tried could fix it.

Luckily I had backups, but I didn't need them because the files are still all there.

The only way to login was through a new user newuser. But all my aliases and mounting places are on olduser or pointing to it (aliases). Also my ssh points to olduser.

For example, my other partitions are on /media/olduser/, aliases point to /home/olduser/Desktop/.

So,

My question is: how can I rename olduser to foo or whatever so that then I can rename newuser to olduser?


If you are curious, here is my problem and some of the solutions I tried:

Unity doesn't load, no Launcher, no Dash appears

What to do when nothing seems to fix Ubuntu 14.10 stuck after log in?

Unity doesn't load, no Launcher, no Dash appears

2 Answers2

1
  1. Boot to root shell in recovery mode
  2. mount filesystem in read-write mode with mount -o remount,rw /
  3. Delete the new user that you created
  4. Change your username in /etc/passwd file.
  5. Reboot.

Repeat steps 1-2 if you need to undo the changes in /etc/passwd

0

If you have given root a password you can do this without rebooting to recovery mode. Otherwise you'll have to either give root a password (e.g. with sudo passwd root) before you start this procedure or reboot.

  1. Press Ctrl-Alt-F1 and login as root. or reboot to recovery mode and bring up a root shell.

  2. Use vipw and vipw -s to change your usernames in /etc/passwd and /etc/shadow respectively. e.g. change olduser in both files to foouser and then change newuser to olduser.

    • Remember to change the home directory fields for the users.
  3. Do the same with vigr and vigr -s for the /etc/groups and /etc/gshadow files.

  4. cd to the directory where all the user home directories are. This is almost certainly /home.

  5. mv olduser/ foouser

  6. mv newuser/ olduser
  7. Change the ownership and group on all files in olduser/.

    chown -R olduser olduser/

    chgrp -R olduser olduser/

  8. Change the ownership and groups on all files in foouser/

    chown -R foouser foouser/

    chgrp -R foouser foouser/

  9. If you had to reboot to recovery mode, reboot again, and then login as olduser. Otherwise, just press Ctrl-Alt-F7 (or whatever Fn key corresponse to your GUI login screen) and login as olduser

cas
  • 161