Macos – Reset root password or enable sudo on MacOS X Mavericks

macospasswordssudo

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.

Best Answer

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?

Related Question