How to pull yourself out of messing up the /etc/sudoers file

Ok. Sudo does not work anymore. Ubuntu 18.04. Why I used vi instead of visudo - no idea.
user@host01:~$ sudo su
>>> /etc/sudoers: syntax error near line 23 <<<
sudo: parse error in /etc/sudoers near line 23
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
user@host01:~$ 

The internet suggests to use "pkexec bash" which should get a root shell... but it does not work either:

polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie

All lost ? reboot in safe mode ? Unfortunately machine is very far away.

Turns out not all is lost. First, in the current session issue "echo $$" and note the PID.

Then make *another* session, and there issue "pkttyagent --process PID_FROM_PREVIOUS_STEP". It will ask for your authentication and will start. Then retry in the first terminal. Congrats, now it works. Yay.

Now quickly launch visudo and fix that stupid error... :-)

Index of /blog/2020-06-03-How-to-pull-yourself-out-of-messing-up-the/

NameLast ModifiedSizeType
Parent Directory/ -  Directory
lighttpd/1.4.33