[Linux command] su \su-\ sudo

Source: Internet
Author: User

1, Su

Command function: The role of SU is to change the identity of other users, except for superuser, you need to type the user's password.

How to use: 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 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 Display description file –version display version information

User: To change the user account, ARG: Incoming new shell parameters.

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 the normal user, from the root switch to the user does not need a password;

B> under normal user, enter SU [username] prompt Password: Enter the user's password, then switch to the user;

2, Su-

Su is switching to another user, but does not switch environment variables (which can be viewed with the Export command); Su-is the complete switch to a user environment;

Therefore, we recommend that you switch users, as far as possible to use su-linuxso such as otherwise may find certain commands can not be executed;

3. 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 command] su \su-\ sudo

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.