I could not login and I could not sudo. My password is invalidated. Somehow I made a terrible error in editing /etc/password and most probably /etc/shadow and /etc/gshadow. This previous post explains this. I can’t even run grpck to check the sanity of the config files.
I went ahead and reboot. Then pressed the Shift-key to get to the grub menu. Highlight the Advanced setttings for Grub, then pressed Cntrl-e. Find the line headed by the world linux then appended “init=/bin/bash”. Pressed Cntrl-x to reboot. Then I get a bash shell prompt. Then because the kernel is mounted read-only I had to remount it read, write. so,
$ mount -n -o rw /
Then we can set our new passwords, without being prompted the old ones.
$ passwd [Enter]
$ newpassword: ……
This sets the root passwords. Let’s test that first. We reboot.
$ reboot -f
We fix the existing user’s password in the root terminal. I like to login to my root account once in a while. This is a few of those cases.