sudo in OS X with non-admin account

I try to keep my Mac nice and secure so I run my everyday account ben with non-administrator privileges and keep an admin account so when I install Apps or use Software Update I will be asked for the admin user and password. This works just fine, but when I attempt to

sudo

from the command-line: Fail.

For example I was attempting to update Rails to version 2.2;

gem update rails

this of course failed, so I tried;

sudo gem update rails

When asked for my password, the admin password would fail, and my ben password would fail too with the error “ben is not in the sudoers file”. I expected the ben everyday-user to fail, but how to get my admin user to step up to the plate and take over?

Well I found the secret from here and it worked beautifully. Simply type

su <admin username>
sudo <command>
password: <admin password>

Yipee, sudo from OS X terminal, finally.

And type

exit

to restore to your previous account prior to running su.

2 Responses to “sudo in OS X with non-admin account”

  1. a Says:

    THANK YOU!!
    It was driving me insane..

  2. Halloween Says:

    Thanks a million!