previous contents up next

Unix for Advanced Users

15. Advanced Commands and Usage

15.10. Becoming Superuser or another User: su

The superuser account is a privileged account with unrestricted access to all files and commands. There are two ways to become the superuser. The first is to log in as root and the second is to execute the su (short for superuser) command while logged in under another username.

After entering the command, the system will prompt you for the root password. Success is greeted with the number sign (#) indicating that you are now the superuser. Failure is greeted with the terse apology "Sorry."

By default, running su inherits all of your environment variables from the shell you were using at the time. If you would like to simulate a root login shell (thereby executing all of root's configuration files) then you need to type:

su -

Excercise extreme caution when using su and the root account. It is easy to lose sight of how much power you wield. It is a terrible thing to accidently overwrite someone's work in progress.

Becoming another user:

Another use of the su command is to become another user. The usage is

su <username>

You will be prompted for the other user's password, of course. As previously, you can do a

su - <username>

to simulate an actual login.

previous contents up next