Switch User Command in Linux

Switch user command (su) has the following forms:

su

Switch to , without loading environment variables. If is omitted (only "su"), it equals to "su root";

su -

Switch to , and loading environment variables. "-" is the abbreviation of "-l", which means this is a "login" shell, so all .profile will be sourced (man su for details). If is omitted (only "su -"), it equals to "su - root";

su -c ""

Run command with the identity of another user. It is mostly used in one-off command with root privileges:

su -c "" root

The double quotes around can't be omitted.

原文地址:https://www.cnblogs.com/darkmatter/p/3605647.html