||Oracle Tips by Burleson
Switch to a Different User
It is often necessary to switch your identity to a different user.
instance you may want to switch from your regular user login ID
(in my case terry) to the root logon in order to set up a new
directory structure with appropriate access permissions (discussed
in a later topic). Instead of logging off as terry and then logging
as root, the su, switch user (or sometimes called super user)
command facilitates an easy switch.
As with other commands, the su command has a number of
available options, but the ones I find most useful are the - option
which essentially logs you into a new shell as the specified user
with the specified user's profile and the -c option which allows
you to run a command as the specified user. Without using the -
option, your current profile is maintained when switching users
and your environment variables, such as PATH for locating
executables, remain unchanged.
Unless you are logged in as root, you will be asked for a password
when you attempt to switch users. When you want to switch back
to your former user identity, you end the switched shell by using
the exit command.
The above book excerpt is from:
Working Examples of Linux Command Syntax