su command
Switch to another user, usually root.
- Users & permissions
- Package util-linux
- 3 options · 4 examples
Syntax
su [options] [user]Provided by the util-linux package. Run man su for the full manual.
Common options
| Option | What it does |
|---|---|
- / -l | Full login shell for the user |
-c CMD | Run one command |
-s SHELL | Use this shell |
Examples
Become root with a login shell
su -Switch to another user
su - aliceRun one command as a user
su - alice -c "whoami"Use a shell for a nologin account
sudo su -s /bin/bash www-data
No example matches. Check the options table or search the guides.
Tips
su -loads the target user's environment; plainsukeeps yours.
su guides
- su Command in Linux with Useful Examples Linux Commands · Updated Apr 2025
- Difference Between `su` and `su -` Commands in Linux Linux Commands · Updated Apr 2025
- Understanding the su Command in Linux Linux Commands · Updated Apr 2025
- Understanding the difference: “sudo su -” And “sudo -i” Linux · Updated Apr 2025
