If you edit the accounts file
/etc/passwd and make a mistake bad things can happen.
More commonly since the root user is the one that is at the first line, wrong edits can get you locked out of sudo and other services if this line takes harm.
Also if you make mistakes with your sudo configuration at
/etc/sudoers.d/ you will probably get locked out.
This post will explain what to do if one of the above happened. I will cover solutions that are working on dedicated servers. That means the machine is not beside you, more commonly they are in a datacenter of your choice. But they are working also on every other machine as long as its Linux, of course...
What does the error "sudo unable to initialize policy plugin" mean?
This error comes normaly with "sudo unknown user: root" in place or if you made a mistake in one of sudos config files. The sudo service is unable to find the user root or is unable to determine over sudo if permissions are valid and therefore is unable to run the requested action with root privileges. Every action you do with sudo will be done with the user root
"I just overwritten the first line in
/etc/passwd what can I do?"
Requirements: - noVNC Console - access to console via vSphere client or similiar
Connect to your noVNC console or vSphere console and then press
DELETE the machine will now reboot.
On the GRUB bootloader selection screen switch to
Recovery Mode and edit the boot startscript by pressing the
E key. Find a line starting with linux and append
init=/bin/bash to it at the end on the same line.
Linux will now boot into recovery and will provide a root shell.
The filesystem will be sure readonly. We can change this by typing this command:
mount -o rw,remount /
When thats done we can edit our passwd file at
/etc/passwd and fix the errors we made.
"I just did some mistakes with my sudoers files, help!"
Requirements: - root account activted and password known
Open your terminal and type
su root, you will be asked for the root password. After you entered this you can edit the sudoers files as root and revert any changes you made.
If you have no active root account / root password then use the method above to fix this.