commands.sh

su

linux

Switch shell to another user.

More info →

Options (4)

-c, --commandboolean

Execute a command as another user

Example: su - {{username}} {{[-c|--command]}} "{{command}}"
-s, --shellboolean

Switch to a given user and use a specific shell (e.g., Zsh, fish, Bash)

Example: su {{[-s|--shell]}} /{{path/to/shell}} {{username}}
-h, --helpboolean

Display help

Example: su {{[-h|--help]}}
-V, --versionboolean

Display version

Example: su {{[-V|--version]}}

Examples (7)

Switch to superuser (requires the root password)

Switch to a given user (requires the user's password)

su username

Switch to a given user and simulate a full login shell

su - username

Execute a command as another user

su - username [-c|--command] "command"

Switch to a given user and use a specific shell (e.g., Zsh, fish, Bash)

su [-s|--shell] /path/to/shell username

Display help

su [-h|--help]

Display version

su [-V|--version]
made by @shridhargupta | data from tldr-pages