Back to the command reference

su

UsersFundamentals In real Linux

Switch to another user

Name: su = substitute user (switch user)

This command needs a real Linux system; you can practise it in real Linux mode.

Full man page

Description

su starts a shell as another user, root by default, asking for the **target user's** password. su - also loads that user's login environment (home, PATH …), which is usually what you want.

Many systems leave root without a password and prefer sudo.

Syntax

su [OPTION]... [USER]

Common options

-Load the target user's environment (recommended)
-l / --loginLike -: a full login (their environment and home directory)
-c / --command COMMANDRun a single command as that user
-s / --shell SHELLUse SHELL instead of the user’s shell

Examples

  • $ su - alice

    Become alice

    Explain
  • $ su -

    Become root (needs the root password)

    Explain

Related