su

Used to switch the current user identity to another user identity

Supplementary instructions

su command is used to switch the current user identity to another user identity. When changing, you must enter the user account and password to be changed.

grammar

su(option)(parameter)

Options

-c<command> or --command=<command>: After executing the specified command, the original identity will be restored;
-f or --fast: applies to csh and tsch, so that the shell does not need to read the startup file;
-l or --login: When changing the identity, the working directory, as well as HOME, SHELL, USER, and logname will also be changed at the same time. In addition, the PATH variable will also be changed;
-m, -p or --preserve-environment: Do not change the environment variables when changing the identity;
-s<shell> or --shell=<shell>: Specify the shell to be executed;
--help: display help;
--version; display version information.

Parameters

User: Specify the target user to switch identities.

Example

Change the account to root and exit back to the original user after executing the ls command:

su -c ls root

Change the account to root and pass the -f option to the newly executed shell:

su root -f

Change the account to test and change the working directory to test's home directory:

su-test
继续阅读

接下来你可能需要这些内容

优先推荐相关内容,同时保留你的阅读轨迹和收藏入口。