HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

su — Switch shell to another user. More information: <https://manned.org/su>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
shellcommandanothercliusersumoreswitch
linux

Problem

How to use the su command: Switch shell to another user. More information: <https://manned.org/su>.

Solution

su — Switch shell to another user. More information: <https://manned.org/su>.

Switch to superuser (requires the root password):
su


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]}}

Code Snippets

Switch to superuser (requires the root password)

su

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}}

Context

tldr-pages: linux/su

Revisions (0)

No revisions yet.