Fix Ubuntu sudoers file with LiveCD

eat my own shit

Fix Ubuntu sudoers file with LiveCD

Yes, bored at home and broken sudoers file.

I want add a without password command for my user, for successfully renew certificate and reload Nginx after installed certificate. I don't want acme.sh running with root account, but I need reload Nginx, so I do that, and modify sudoers file.

The default editor is nano, actually I don't like it, but I just add one line and save, I think I can do it perfect, after I quit and save file, I test if it works fine, I found there is something wrong with sudoers file, I don't know why, but I know I can't use sudo command any more.

Someone suggest use pkexec visudo, but I failed with authentication. I have to restore it on other underlying ways, e.g. enter recovery mode and modify file.

But I don't know how to enter recovery mode, I searched, someone said press Shift key during boot, I have a VNC connection, but I can't press Shift key during booting, when I reboot the VM, VNC disconnected, and when I connected, the system almost boot finished.

I setup boot from CDROM and insert(specify ISO image) LiveCD, when I connected VNC, I saw progress stoped at language choose menu, I found a official document, said press Ctrl+Alt+F1, open another session, it doesn't work for me, I think it changed from some version.

Finally, I found a menu item hidden in top right [Help], there is a [Start Shell] item, I got the root shell.

Just mount the root partition, sda2 is my root partition, and sda1 is boot partition, then I modified sudoers file.