Reset root password or enable sudo on MacOS X Mavericks

3

2

I have a MacOS X Mavericks installation with a single user Admin and empty password for that account:

screenshot

Now I'm trying to install Cocoapods, but can't use "sudo", because I don't know the root password:

admin@mac:etc> id
uid=501(admin) gid=20(staff) groups=20(staff),401(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)
admin@mac:etc> id root
uid=0(root) gid=0(wheel) groups=0(wheel),1(daemon),2(kmem),3(sys),4(tty),5(operator),8(procview),9(procmod),12(everyone),20(staff),29(certusers),61(localaccounts),80(admin),401(com.apple.sharepoint.group.1),33(_appstore),98(_lpadmin),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)
admin@mac:etc> sudo gem install cocoapods

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts

On Linux I would boot the machine in single user mode and set the root password. Or add Admin user to wheel groupd and uncomment this line in /etc/sudoers:

%wheel  ALL=(ALL)       NOPASSWD: ALL

But in MacOS I don't know what to do.

I also can't find the /etc/sudoers when I run text editor or MacVim.

Alexander Farber

Posted 2014-01-12T18:52:52.077

Reputation: 233

Answers

7

Have a look at this Apple Support article. It states:

If your administrator account has no password (a blank password), you must give that user a password before using the sudo command.

After you are done using the sudo command, you can change your account password again, although it is recommended that your administrator account have a non-blank password.

Is there a reason why you can't change the password for this user?

ƘɌỈSƬƠƑ

Posted 2014-01-12T18:52:52.077

Reputation: 358

10

Straightforward, you actually have to enable the root user.

1. Click on on Login Options, then unlock the greyed out screen by clicking the Lock icon in the bottom left hand corner, and either Join or Edit Network Account Server.

2.Then choose Open Directory Utility. Click the lock again and authenticate.

3. Go up to the menu bar at the top and you have the option to Enable Root user or if its already enabled change the password.

That is one way to do it.

notantisocial

Posted 2014-01-12T18:52:52.077

Reputation: 121

didn't grok that "either Join or Edit Network Account Server" but the rest of it helped.. – ari gold – 2016-01-14T20:48:54.040