I have broken my Ubuntu Server VM, which is hosted on Xenserver, by improper entry in /etc/sudoers. Hence, I was stuck without the possiblity to run any command with sudo.
The solution in case of a desktop installation is to press ESC during boot and then simply select a recovery console in GRUB. However, no matter how fanatically you will press ESC when booting VM through Xenceter, AFAIK you would not be able to access the Recovery Console.
In some posts (eg. here or here) people recommend to start the VM in Recovery Mode that is provided by Xenserver (accessible by VM -> Start/Shutdown -> Start in Recovery Mode). The problem is that by default in this mode the system starts to boot from CD/DVD. This would be ok if Ubuntu Live CD would work in Xenserver, but it doesn’t! (vide this question on StackExchange).
Luckily, there is a simple solution! The Root Console can be called directly by change the VM boot options (eg. through Xencenter):
Backup! Make a snapshot of the problematic VM.
Right click on the problematic VM -> Properties, then go to the Boot Options tab.
Modify OS Boot Parameters from:
-- quiet console=hvc0
Boot/reboot the VM normally and select Drop to root shell prompt
Voila! Now you can perform as root the operations needed to recover the system.
Change back the OS Boot Parameters and reboot.
Somehow this is not described in Xenserver docs. I have fond it here.