【Linux】命令 - su

Posted by 西维蜀黍 on 2021-08-22, Last Modified on 2022-12-10

To confirm that the user is changed, use the whoami command:

$ whoami
# 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"

Reference


TOC