How to fix sudoers file on virtual machine without root and reboot

sudovirtual-machines

I've broken my sudoers file on a heavy loaded server with a syntax error. And unfortunately I've lost my root password. The server is critical and I'd like to avoid rebooting. So, no sudo, no root, no reboot, no kdesudo or gksu. The server is a virtual machine running on kvm.

How would you fix this?

Best Answer

This is not a general solution, but I'm posting this as an inspiration for people in the same situation.

I didn't have access to solutions mentioned so far but I was very lucky to have access to a cron task that ran as root. I used that cron task to run another script that fixed /etc/sudoers and from now on I will use only visudo.

So if you are in this situation cron tasks can be helpful. No downtime/server restart and no risk to mess up data with dd.