Many commands used to manage a server must be executed by an administrator user or the root user.
For example, entering server:~ mariah$ shutdown
gives you the following error: shutdown: NOT super-user
This is because the shutdown
command can be run only by the root user or by an administrator user with root user privileges. The root user is also called the superuser.
To run commands with superuser privileges, use the sudo
command. sudo
stands for “superuser do.”
The following example works on computers with OS X installed, so don’t run it unless you want to restart your computer:
server:~ mariah$ sudo shutdown
You’ll be prompted for the password of the current user.
Only administrator users can use sudo
. If you’re not logged in as an administrator, you can do so by entering the following, where adminUsername is the name of an administrator user:
su adminUsername
You’re asked to enter the password for adminUsername, after which a new shell is opened for that user.
If a command requires it, you can use su
to switch to the root user. Under normal circumstances, you shouldn’t log in as the root user.
Important: If you use su
to log in as the root user, be especially careful, because you have sufficient privileges to make changes that can cause your server to stop working.
For more information about the sudo
and su
commands, see their man pages.