The most advanced tasks demand the most powerful user account of them all: the root user. When you log in as root, you have read and write privileges to every file on your Mac. This awesome power lets you override any account or permission restriction, but be careful! You could really mess things up if you don’t know what you’re doing.
Warning: The root account is disabled by default. To prevent accidents, you should only enable and utilize the root account when you absolutely need it.
Acting as Root with Sudo
Before you enable the root user account on your Mac, you should know about an alternative called
sudo
. As in other Unix-based operating systems, this command allows administrators to temporarily act as the root user in Mac OS X . Just open the Terminal application and preface a Unix command with sudo
, as shown below.Most commands can be executed with
sudo
, but you’ll need to authenticate with your administrator password to execute the command as root. System administrators consider usingsudo
a best practice - you should always try using sudo
before you log in as root!Enabling the Root User Account
Ready to turn on your Mac's superuser account? Here’s how to enable the root user account in Mac OS X and set the password:
- From the Apple menu, select System Preferences.
- Select Users & Groups.
- Click the lock and authenticate with an administrator account.
- Select Login Options.
- Click Join, as shown in the figure below.
- Click Open Directory Utility. The Directory Utility window appears.
- Click the lock and authenticate with an administrator account.
- From the Edit menu, select Enable Root User.
- Enter the password for the root user in the Password and Verify fields.
- Click OK to enable the root user and save the password.
Logging in as Root
Now you can log in as the root user at the Mac OS X login screen. When the list of users appears, click Other, type
root
in the Name field, and enter your root password in the password field. You'll be logged in as root until you log out, restart, or shut down your computer.Note: To log in as root from the OS X login screen, you must have automatic login and FileVault disabled. Follow the instructions in our How to Password Protect Your Mac tutorial.
If you're an expert at the command line and would rather not log in to your computer as the root user, you can enter the
su
command in the Terminal application. Enter the root user account password and you'll be acting as the root user for the duration of your Terminal session, or until you type exit
.Remember, you should only log in as the root user when absolutely necessary.
Disabling the Root User Account
Once you've used the root user account to flex your superuser muscles, you should consider disabling it for security purposes. Here's how to disable the root user account in Mac OS X:
- From the Apple menu, select System Preferences.
- Select Users & Groups.
- Click the lock and authenticate with an administrator account.
- Select Login Options.
- Click Join, as shown in the figure below.
- Click Open Directory Utility. The Directory Utility window appears.
- Click the lock and authenticate with an administrator account.
- From the Edit menu, select Disable Root User. The root user is now disabled.
Final Thoughts
These instructions are written for Mac OS 10.7 and 10.6. If your Mac is running an earlier version of Mac OS X, follow the instructions provided on Apple's Support to enable the root user on your computer.
Retweet this story