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

2 thoughts on “Breaking teh sudoers file on OS X

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s