Ubuntu: borked my sudoers file, how can I fix it?

Solution 1:

You should never edit your sudoers file directly. Use visudo - it will protect you from these syntax errors in the future.

To recover from this situation, either boot into single-user mode and edit the file or boot off of a livecd and do the same.

Solution 2:

Boot the system into single mode and then edit it.


Solution 3:

As noted in this similar question on askubuntu, this may well work without having to reboot into single-user mode:

pkexec visudo

Solution 4:

If you have Docker installed and your user is a member of the docker group you can easily get yourself out of this pickle (and some others) without rebooting or what-have-you:

  1. $ docker run -it --rm -v '/etc/:/root/host.etc/' debian bash
  2. apt-get update && apt-get install [vim|nano|whatever]
  3. cd ~/host.etc/
  4. Repair the problem files
  5. exit

Tags:

Ubuntu

Sudo