Suppose you mounted your install Ubuntu system's root filesystem at
/mnt on the transient live CD system, and that the partition is
Then remount it readwrite:
sudo mount -o rw,remount /dev/sda1 /mnt
- If that fails, unmount the filesystem (with
fsck it to find and repair any errors (see also
Then you can edit its
sudoers file like this:
sudo visudo -f /mnt/etc/sudoers
Actually, you can edit it as
root using whatever mechanism you want. For example, to edit it in such a way as to allow you to introduce errors that break it and prevent
sudo from working:
sudo -e /mnt/etc/sudoers
visudo is better because it won't save your changes to the file if they are syntactically wrong.
visudo when editing
/etc/sudoers on your installed system (from the installed system), you avoid having to boot into recovery mode, or to a live CD, to fix it.
If you do break your
sudoers file, you can fix it without booting into recovery mode or rebooting, because there is another mechanism besides
sudo for becoming
pkexec is the command-line frontend to PolicyKit. It is generally not present on server systems without a GUI, but it will be present on virtually any Ubuntu system with a GUI (and you do not actually need the GUI to be working to use it, though if there is a GUI it will give you an authentication window rather than authenticating in the terminal itself).