The default Mac OS X installation has the Unix "root" account disabled. This is generally a good thing, because the casual user does not need all the powers granted to this "superuser" account. But it can be useful to be able to become "root" to fix something. You can follow the instructions below to enable the "root" account, which will make it easier for the "root" user to get a command shell prompt.
You can also use these instructions to remove a root password that you have forgotten, or to reset any user password.
Making changes like this to the system requires administrative privileges. You will need to know the password for the "Admin" account on your machine. If you do not have that then the only way to get administrative access to the machine is to reboot from an Installation CD and find the menu item for "Password Reset".
Whenever you use the "root" or "Admin" accounts it is a good idea to follow the Principle of Least Privilege. You should only take on the extra privileges to do a particular job, and then release those privileges when you are done. (Your normal, every day user account should not have administrative privileges!)
If you just want to perform occasional system administration tasks then you don't really need to enable the "root" account. You can log in as the "Admin" user, open the Terminal application, and give any single command prefixed by the sudo command. Examples of this are shown below.
Since this page first started I have become aware of three different ways to enable the root account. The original way I published is the "detailed" method using NetInfo Manager. It is the same way you would reset any user's password on a NeXT computer (and now Mac OS X as well). There is also a much quicker way to enable the root account using a menu item in NetInfo Manager. Or you can open a command shell in the Terminal application and use the sudo command. Pick the one that works best for you:
After you have enabled the root account, there are three different ways that you can become "root" to perform system administration tasks.
Whenever you use the "root" or "Admin" accounts it is a good idea to follow the Principle of Least Privilege. You should only take on the extra privileges to do a particular job, and then release those privileges (i.e. go back to using your normal user account).
The sudo command is a good way to do this, because it runs only one command as the "superuser" at a time. For example
% sudo cat /etc/sudoers
will show the contents of the sudoers file, which controls who is allowed to use the sudo command. You will have to give your password for any "sudo" command to work, and your account must be listed in the sudoers file.
If you need to do something which requires more than a single command then you can open a command shell running as "root". You can still use the sudo command to do this. When logged in as the "Admin" user open the Terminal application and give the command
% sudo tcsh
This will spawn a new tcsh command shell running as "root". You can give as many commands as you need, and then type `exit` when you are done.
On MacOS X the "Admin" account is configured so that it is allowed to use the "sudo" command, so you can get by without enabling the "root" account.
The more traditional way to become "root" in Unix is the su command. This will work for the "Admin" user but will fail for a non-privileged user account because of another old Unix custom which is respected by Mac OS X: only members of the "wheel" group are allowed to su to root.
There are two ways around this. First of all, you can use NetInfo Manager (as described below) to add your user account to the "wheel" group. Follow the instructions below to run NetInfo Manager, but select the "groups" map instead of the "users" map. Find the "wheel" group, edit the "users" property, and add the name of your user account to the list.
But there is an easier way. Local users who are not in the "wheel" group cannot su to "root", but can still ssh to the "root" account. Give the command
This is the easiest method to enable the "root" account on a Mac if you are more of a GUI person:
Macintosh HD -> Applications -> Utilities -> NetInfo Manager.If you don't have this in the dock for the Admin account you should probably drag it there. It is very useful for system administration.
This is the easiest method to enable the "root" account on a Mac if you are more of a CLI person:
Macintosh HD -> Applications -> Utilities -> Terminal.
The first password you are asked for is the already existing password for the Admin account, to prove that you are authorized to make changes to this system. After that, you enter the new root password (twice, for verification). That is all, the "root" account is now enabled, with that password.
% sudo passwd root Enter Password: Changing password for root New password: Verify password:
These instructions allow you to enable the "root" account, or to reset the password for any user, not just "root".
Macintosh HD -> Applications -> Utilities -> Terminal
% nidump passwd .
2. To remove the "*" (or any old password) you can run the NetInfo Manager application, which is also in the Utilities folder:
Macintosh HD -> Applications -> Utilities -> NetInfo Manager
3. With "/" in the left column select the "users" map in the second column and click on the ""root"" user.
4. Click on the lock icon at the bottom of the window marked "Click to make changes". Enter the administrative password as prompted. You are now free to make changes to the users map.
5. Find the "passwd" property and double click on the value field to alter it (it should contain just the "*", or possibly an old encrypted password). Delete the "*" and make sure there are no spaces left in the value field.
You cannot simply enter a new password here, because Unix stores an encrypted version of the password in the user database (passwd map). You will need to use the passwd command (step 7 below) to enter a new password.
6. Pull down the "Domain" menu from the top bar and select "Save Changes". Confirm that you really want to make the change. At this point your computer has the root account enabled with no password, which is very dangerous.
7. Log out and log in as the "root" user to verify that it worked. If the login screen shows a list of users it won't show the "root" user so you will have to select "Other".
8. It's very useful for the "root" user to have the Terminal application always in the Dock. Here is how to do that:
(Macintosh HD -> Applications -> Utilities -> Terminal)
To disable the "root" account, or any user account, follow the directions above to edit the "user" map with NetInfo Manager, and put a "*" in the passwd field.
Many thanks to all those who have given me feedback on this page, including Stephen Zinn and Damian Draper.