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
| Flag | Meaning |
|---|---|
| - | A login shell: take that user environment, PATH and home |
| -l | The same as the bare dash |
| -m | Keep your own environment instead |
| -c | Linux: run one command and exit. macOS su has no -c |
| -s | Linux: use another shell |
Examples
su - deployBecomes deploy, with the deploy environment.
su -A root shell, if the root password is set at all.
sudo -iWhat 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