Becoming Superuser
On a Unix system, the superuser refers to a privileged account with unrestricted access to all files and commands. The username of this account is root. Many administrative tasks and their associated commands require superuser status.
There are two ways to become the superuser. The first is to log in
as root directly. The second way is
to execute the command su while
logged in to another user account. The su command may be used to change one’s current
account to that of a different user after entering the proper password.
It takes the username corresponding to the desired account as its
argument; root is the default when
no argument is provided.
After you enter the su
command (without arguments), the system prompts you for
the root password. If you type the
password correctly, you’ll get the normal root account prompt (by
default, a number sign: #), indicating that you have successfully become
superuser and that the rules normally restricting file access and
command execution do not apply. For example:
$ su Password: Not echoed #
If you type the password incorrectly, you get an error message and return to the normal command prompt.
You may exit from the superuser account with exit or Ctrl-D. You may suspend the shell and
place it in the background with the suspend command; you can return to it later
using fg.
When you run su, the new shell
inherits the environment from your current shell environment rather than
creating the environment that root would get after ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access