SU(1,C) AIX Commands Reference SU(1,C)
-------------------------------------------------------------------------------
su
PURPOSE
Obtains the privileges of another user, including superuser authority.
SYNTAX
+-----+ +------+ +- root -+ +------------------+
su ---| |---| |---| |---| |---|
+- - -+ +- -f -+ +- user -+ +- -c "cmdstring" -+
Warning: See restrictions, Chapter 18, AIX Programming Tools and Interfaces.
DESCRIPTION
The su command runs a shell and lets you operate in it with the privileges of
the specified user (by default, "root").
If you use su to become the superuser (the user argument is "root"), the su
command sets the PATH variable to /bin:/usr/bin:/usr/ucb:/etc, sets the $HOME
variable to "/", and changes the prompt to "#" (number sign). The PATH
variable does not include the current directory. If you are not already
operating with superuser authority, the su command prompts for the password
associated with user before granting these privileges.
To restore your normal privileges, use the standard procedure for exiting from
the shell. This often is pressing END OF FILE (Ctrl-D). This action ends the
shell called by su and returns you to the previous shell and ID.
If you need to run only one command as user, you can run the desired command by
including it (along with any of its associated flags) on the command line as an
argument to the shell -c flag (see "sh, Rsh" for a description of this flag).
In this case, su calls sh to run the command and then exits automatically.
Each time someone uses su to become the superuser, su writes a record in the
file /usr/adm/sulog, creating this file if necessary. This record is written
regardless of whether su is successful.
Note: If the -c option is not specified, su execs the shell listed in the
shell field of the /etc/passwd file. If the -c flag is specified, su
ignores the passwd file entry and runs /bin/sh. All exported
environment variables are available unless you use the - flag when you
call su.
FLAGS
Processed November 8, 1990 SU(1,C) 1
SU(1,C) AIX Commands Reference SU(1,C)
- Creates the same environment for the new shell as the login
shell of user. This is done by calling the new shell as a login
shell (see "sh, Rsh"), so it reads the system profile file and
the user's $HOME/.login or $HOME/.profile file, depending on the
shell. The environment variables LANG and LC_TIME control the
appearance of the date and time. The TERM and TZ variables are
an exception. They are preserved at their current values.
These variables are normally set by init or getty prior to
login; so su handles them differently.
Note: This flag modifies the environment of the current shell
only if the optional program named in the shell field of
the passwd file is a program like sh that expects to be
called as a login shell.
-c "cmdstring" Runs the /bin/sh shell, processes the specified command, and
then exits the shell. This flag causes su to ignore the shell
specified in the passwd file.
-f Prevents sourcing of the .cshrc or .kshrc file for the user
being substituted, hence making start-up faster.
EXAMPLES
1. To obtain superuser authority:
su
This runs a subshell with the effective user ID and privileges of user
"root". The su command asks for a password, as if you were logging in as
"root". Now the commands you run have superuser authority. Press END OF
FILE (Ctrl-D) to end the subshell and return to your original shell
session and privileges.
2. To obtain "ann"'s privileges:
su ann
This runs a subshell with the effective user ID and privileges of "ann".
3. To set up the environment as if you had logged in as "ann":
su - ann
This runs a subshell with the effective user ID and privileges of "ann".
The - causes the shell variable LOGNAME to be set to "ann", HOME to be set
to the path name of "ann"'s home directory, and "ann"'s $HOME/.profile
shell procedure file to be run before prompting for the first shell
command.
4. To run a single command with superuser authority:
Processed November 8, 1990 SU(1,C) 2
SU(1,C) AIX Commands Reference SU(1,C)
su root -c "backup -9 -u"
This runs the shell command "backup -9 -u" with superuser authority (if you
know the password assigned to "root").
RELATED INFORMATION
See the following commands: "sh, Rsh."
Processed November 8, 1990 SU(1,C) 3