1

I did something REALLY silly - I did ... sudo vi /etc/passwd Then I changed the username to the user I wanted, I exited the file.

Now - the user password no longer matches, I can't change the password as I can't enter the current password. I can't sudo (as the password no longer matches). I'm still logged in though.

Is there a way out? I encrypted the disk - if I take it out, can I mount it on another machine?

Sam

  • If that last one works you can do that from a live session. And a live session is likely to work better and easier than taking it out. Have a look if that works 1st and then report back ;) – Rinzwind Jun 28 '18 at 14:54
  • 1
    If you still have a local session open, sometimes pkexec works in situations where sudo doesn't - try pkexec vipw (or pkexec vipw -s if you wish to change the shadow file to be consistent with the modified passwd file). – steeldriver Jun 28 '18 at 15:52
  • I have the same issue, the problem is that it asks for root user password wich i dont know.@steeldriver – Tiago_nes Dec 26 '18 at 18:46

2 Answers2

1

I just did the following and solved my issue:

su - newusername /* will prompt for password */

I entered the old password and that worked!

0

You have to change the username in /etc/shadow too. Then the name/password will match and should work. Check the /etc/group and /etc/gshadow files too for the old username, and change if necessary. Then check the /etc/sudoers file,... etc.
Probably, you should just have added a new user (useradd), added the new user to sudoers, and when things work, delete the old user.

ubfan1
  • 17,838