Tag Archives: sudoers

Breaking teh sudoers file on OS X

Not having anything better to do, I horked my sudoers file while modifying an entry, thereby preventing myself from sudoing at all (and subsequently fixing it). Weak.

Turns out there’s a pretty easy fix for this using the Finder, so long as your account has administrator privileges:

Steps:

  1. In the Finder, go to /etc (or do <cmd>-<shift>-g and enter /etc, if you don’t see it in the Finder)
  2. Get Info on sudoers
  3. In the Info window’s Sharing & Permissions section, add an entry for your local user with read and write access
  4. With a text editor, edit /etc/sudoers and fix the problem.
  5. Fix the permissions on /etc/sudoers back to 0440.
  6. Enjoy your newly-regained sudo power!

Of course, this can be used to overcome other permissions problems too.

If only visudo had a validator, along with a syntax checker…

Advertisements