Forgetting the root password on Mac can feel like a disaster but you can easily recover it using a sudo command if you have the password to an administrator's account on the system.

Open a terminal window and type:

sudo passwd root

You will be prompted for your password (the password to the administrator's account). After that you will be prompted for the new root password twice.

The sudo command is a great tool to control who can do what on a system. In this scenario the sudo command allows you after authentication with the user password to run a command as if you were root. The command passwd root is the command to change the password for the root user.

Update 01/16/08 How to reset lost root password by switching to single-user mode (Command-S) known as command line interface in Unix. (Suggested in user comments.)

Reed more on how to change your lost root password with an Install Disk.

3 comments 3 comments ( 1512 views )

No UserpicSasha
01.16.09
there is a whole thread dedicated to this topic on http://macosx.com/forums/archive/t-264944.html

also, if you have FireVault enabled, you might loose it's content. just a thought.

No UserpicAlex
01.16.09
Marius,

below is similar approach with some explanation:

Restart your computer, hold down Command-S. This puts you into single-user mode, where the monitor displays text known as a command-line interface.

Type in the following:
/sbin/fsck -y Enter
/sbin/mount -uaw Enter
rm /var/db/.applesetupdone Enter
reboot Enter

The rm command is the remove command which deletes the user account file.
Next you will be presented with the OS account setup where you will create a new admin-user account.

No UserpicMarius
01.16.09
What about this instead !

1) Reboot the computer.
2) Hold apple and s at start-up.
3) Type Mount -uw / then hit return
4) Type rm /var/db/.AppleSetupDone and hit return
5) Type reboot press return and wait
6) Type in all information needed.
7) go to system preferences.
8) Accounts
9) Click lock button and enter password.
10) click account you want to reset the password on and click reset password.´