I’ve complained many times here (including my most recent post) about all the shortcomings of the Mac OS X Finder. But thanks to the foundation upon which the OS was written (Nextstep, a flavor of Unix), we do have access to a VERY powerful command line. But that command line won’t do some of the more important (and interesting, but also dangerous) work unless you have root access, which by default is disabled. For Unix geeks like me, it’s tempting just to try to pop open the Terminal application and “su” to root, but until you “enable” the root account by setting the password, you won’t get far. You can preface each command you want to run with “sudo” without enabling the root account, but that gets tedious after a while.
How to enable the root account in Mac OS X (post 10.5 onlyif I’m not mistaken)
- First, if you’re going to try and be a power user, drag the Terminal app to your dock — you can find the Terminal in /Applications/Utilities
- Make sure your logged into an account that has administrator access by going to Apple Menu -> System Preferences … -> Accounts, finding your account and making sure “Allow user to administer this computer” is checked
- Launch the Terminal app and type
sudo passwd root— you’ll have to enter your regular account password once, then the new root password twice (I keep them the same so not to confuse things) - Now, anytime you want root access from the command line, you can just type
su, hit [Enter], enter your password and you’re good to go — don’t forget to typeexitor hit [CTRL]-D to exit this shell when you’re done for your protection
Editing protected files One last tip: if you ever find yourself wanting to edit a file that only root has permissions to, you have two options:
- Follow the instructions above,
cdto the directory you want, and usevito edit the file — but you need to know how to use the vi modal command line text editor, which ain’t an easy undertaking - Or, follow the instructions at this article

4 Comments Received
March 16th, 2011 @12:19 pm
I don’t like the security risk of having the root account enabled, so I set up this simple alias to give me a root shell via sudo:
alias root=’sudo su -’
That’s in my ~/.aliases file, which is sourced by my .bashrc.
You still need to be an Administrator for sudo access, of course, but this means the root account still doesn’t have a password, you just use your account password to get a root shell.
April 22nd, 2011 @3:31 pm
Hmm… Having comment problems. @UltraNurd ( http://www.ultranurd.net ) commented:
I don't like the security risk of having the root account enabled, so I set up this simple alias to give me a root shell via sudo:
alias root='sudo su -'
That's in my ~/.aliases file, which is sourced by my .bashrc.
You still need to be an Administrator for sudo access, of course, but this means the root account still doesn't have a password, you just use your account password to get a root shell.
January 24th, 2012 @8:10 pm
sudo su is a fun whay to go root without having to remember root password
Pingback & Trackback