Mac OS X Gain Root/Superuser Access using sudo

Posted September 21, 2004 by macster in Mac system administration

The command line utility sudo is an effective way to provide fine-grained access control to different applications for different users. In this tech-recipe, sudo will be used to easily gain full root/superuser access to a Mac running OS X.


Under Mac OS X, the root or superuser account is not enabled following installation. While it is possible to enable the root account, it is safer and potentially easier to use the sudo command to gain root access to the system.

From a terminal window, type the following:

sudo -s

This will prompt you for a password which is the user’s password, not the root password (which will not be set). The first time you run sudo, it will print a conscience-oriented message before prompting for the password. Subsequent uses of sudo for that user will not print out that text. The -s option launches a shell as the target user (root). When successfully executed, the shell’s prompt should end with root#.

When done with root privileges, it is a good idea to demote yourself and return to your original user shell by typing the following:

exit

The Conversation

Follow the reactions below and share your own thoughts.