Name

su

Synopsis

    su [option] [user] [shell_args]

Create a shell with the effective user ID of another user (that is, login as user). If no user is specified, create a shell for a privileged user (that is, become a superuser). Enter EOF to terminate. You can run the shell with particular options by passing them as shell_args (e.g., if the shell runs sh, you can specify -c command to execute command via sh, or -r to create a restricted shell).

su will inherit your environment settings. Administrators wishing to switch to a user’s setup (perhaps to help them solve a problem) may wish to consider using this sequence:

    me$ su                   
                     Switch to root
    Password:                Enter root password
    # su - 
                     user              
                     Switch to other user
    user$

The sudo program is worth installing if your system doesn’t have it. See http://www.sudo.ws/ and/or http://www.courtesan.com/sudo.

Common Option

-

Go through the entire login sequence (i.e., change to user’s environment).

-ccommand, --command=command

Run a single command (by way of sh -c).

GNU/Linux and Mac OS X Options

-f, --fast

Pass -f on to csh or tcsh.

-l, --login

Same as su -.

-m, --preserve-environment

Preserve the environment.

GNU/Linux Options

-p

Same as -m.

-sshell, --shell=shell

Use shell if shell is listed in /etc/shells.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.