su
user managementLinux/Unix
The su command is one of the most frequently used commands in Linux/Unix-like operating systems. su Switch user or substitute user
Quick Reference
Command Name:
su
Category:
user management
Platform:
Linux/Unix
Basic Usage:
su [options] [arguments]
Common Use Cases
Syntax
su [options] [username]
Options
Option | Description |
---|---|
-, -l, --login |
Start a login shell; clears environment variables except TERM, runs login scripts |
-c, --command=COMMAND |
Pass a single COMMAND to the shell with -c |
-f, --fast |
Pass -f to the shell (for csh or tcsh) |
-g, --group=GROUP |
Specify the primary group |
-G, --supp-group=GROUP |
Specify a supplemental group |
-m, -p, --preserve-environment |
Do not reset environment variables |
-s, --shell=SHELL |
Run SHELL instead of the default in passwd |
--help |
Display help message and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the su
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
su