1. The command for user Switching in the Linux system is SU, and the syntax is:
su [-FMP] [-C command] [-s Shell] [--help] [--version] [-] [USER [ARG]]
Parameter description
-F, –fast: Do not need to read the boot file (such as CSH.CSHRC, etc.), only for CSH or tcsh two kinds of shell.
-L, –login: After this parameter is added, it is as if it were re-landed, most of the environment variables (such as home, shell, user, etc.) are based on the user, and
and the working directory will also change. If user is not specified, the default is root.
-M,-p, –preserve-environment: does not change the environment variables when performing su.
-C command: Change the user's username and execute the instruction (command) before changing back to the original user.
Help displaying the description file
–version Display version Information
User: To change the user account,
ARG: The new shell parameter is passed in.
2. Differences between Su [user] and Su-[user]:
su [user] switches to other users, but does not switch environment variables, SU-[user] is the complete switch to the new user environment.
Such as:
[[email protected] ~]# pwd--current directory
/root
[[email protected] ~]# su Oracle--Using SU [user]
[[email protected] root]$ pwd--The current directory does not change, or the previous user directory
/root
[[email protected] root]$ su-oracle--Using Su-[user]
Password:
[[email protected] ~]$ pwd--The current directory becomes the home directory of the current user
/home/oracle
[Email protected] ~]$
Therefore, we recommend that when you switch users, try to use Su-[user], otherwise the environment variables may not be the problem.
Transferred from: http://www.cnblogs.com/oradragon/archive/2012/08/30/2664551.html
User Switching in Linux systems (the difference between SU User and Su-user)