Linux su command parameters and usage details--linux Switch User command

Source: Internet
Author: User


We recommend that you use Su-root when you switch users, or you may find that some commands do not
For the difference between Su, Su-and sudo please look down

1. Command function
The role of SU is to change to the identity of other users, except the superuser, who needs to type the user's password.
2. How to use
su [-FMP] [-C command] [-s Shell] [--help] [--version] [-] [USER [ARG]]
3. 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 adding this parameter, as if it were a re-login, most of the environment variables (such as home, shell, user, etc.) are dominated by the user, and the working directory changes. 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.
4. Example
Su-c ls root changes the account number to root and exits to the original user after the LS command is executed.
Su [user name]
A> under root user, enter Su ordinary user. Switch to normal user, switch from root to work without requiring a password
B> under normal user, enter Su [user name]
Hint Password:
Enter the user's password, then switch to the user
Extended read one: What is the difference between a Linux su command and a su-command?
Su is switching to other users, but does not switch environment variables (for example, the Export command to see the difference between the two commands)
Su-is the complete switch to a user environment
So it is recommended that when you switch users, try to use su-linuxso so that you may find that some commands do not
Extended Reading II: The difference between Su and sudo
Because SU does not have the restriction of permissions after switching to Superuser root, SU does not act as a system managed by multiple administrators. If you use SU to switch to the Superuser to manage the system, it is not clear what work is done by which administrator. In particular, for the management of the server with many people involved in the management, it is best for each administrator's technical expertise and scope of management, and a targeted delegation of authority, and agreed on what tools they use to complete their work, then we need to use sudo.
Through sudo, we can put some super-privileged targeted decentralization, and do not need to know the root password of ordinary users, so sudo relative to the unrestricted permission of Su, is still relatively safe, so sudo can also be referred to as restricted Su, and sudo is required to license, So also known as the licensing of SU;
The process of sudo executing a command is that the current user switches to root (or the other user specified to switch to), executes the command as root (or another specified switch to the user), and then returns directly to the current user after execution is completed, which is premised on the configuration file of sudo/etc/ Sudoers to authorize;

Linux su command parameters and usage details--linux Switch User command

Related Article

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.