Skip to content

su command

Switch to another user, usually root.

On this page

Syntax

su [options] [user]

Provided by the util-linux package. Run man su for the full manual.

Common options

OptionWhat it does
- / -lFull login shell for the user
-c CMDRun one command
-s SHELLUse this shell

Examples

  1. Become root with a login shell

    su -
  2. Switch to another user

    su - alice
  3. Run one command as a user

    su - alice -c "whoami"
  4. Use a shell for a nologin account

    sudo su -s /bin/bash www-data

Tips

  • su - loads the target user's environment; plain su keeps yours.

su guides

← All Linux commands · Suggest a fix

Back to top