Home·Terminal commands

su

Permissions

Usage

su - [user]

Becomes another user with that user's own password, the opposite of sudo which asks for yours; leave off the dash and you keep your own PATH, the usual cause of command not found.

Common flags

FlagMeaning
-A login shell: take that user environment, PATH and home
-lThe same as the bare dash
-mKeep your own environment instead
-cLinux: run one command and exit. macOS su has no -c
-sLinux: use another shell

Examples

su - deploy

Becomes deploy, with the deploy environment.

su -

A root shell, if the root password is set at all.

sudo -i

What to use instead where the root account is locked.

Numeric and symbolic modes name the same thing: 755 and u=rwx,go=rx are the same permission.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does su do?

Becomes another user with that user's own password, the opposite of sudo which asks for yours; leave off the dash and you keep your own PATH, the usual cause of command not found.

Q. How do I type it?

su - [user] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man su. This command sits under Permissions.

Related commands

man page: man su