User Switching in Linux systems (the difference between SU User and Su-user)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.