Mario. Web Developer, Snowboarding Addict

Recover /etc/sudoers in Ubuntu 12.04

Note: you should always 'sudo visudo' to edit the sudoers file, it validates the file and thus will prevent you ending up in this situation in the first place!

So I went to edit /etc/sudoers, and mistakenly assumed that the '#' in front of the includedir directive line was a comment. It is not.

So now, if you're silly like me and you weren't making changes as root, you can't sudo to fix your sudo. Oh the irony.

You'll need to:

  • Reboot into recovery mode (hit escape during boot, choose the recovery mode option on the grub screen)
  • Choose the 'Enable networking' option (if you don't your filesystem will be mounted as read-only. who knew)
  • Chosee the 'Drop to root shell' option
  • run visudo, fix your file
  • Reboot with normal grub option

Add new comment

(If you're a human, don't change the following field)
Your first name.

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <div> <h3> <h4>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <javascript>, <php>, <ruby>, <sql>, <text>.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.