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
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.

| improve this answer | |
  • does not work, the system asks me for the password of the new user which is lost. – Tiago_nes Dec 26 '18 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.