Reset root password or enable sudo on MacOS X Mavericks

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.

2 Answers

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?

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like