Chapter14:linux account Management (1) Identity switch

Source: Internet
Author: User

We all use a general account to log into the system, but how to make the general user into a root user, there are two ways:

(1) SU: This command must have root password.

(2) sudo: This command only has its own password, but it has to be set.

One. Su

Any identity switch can be made.

su [-LM] [-C command] [username]

There is no plus-the difference is great. Variable reading methods involving Login-shell and Nologin-shell.

(1) Do not add-

As you can see, the user identity is root, but path is Chuiyuan , that is, the read variable is set to non-login Shell, in which case many variables will not change. In particular, path, because it does not become a root environment (/sbin,/usr/sbin), so many of the commands used by root can only be executed with absolute paths.

(2) plus-

At this point, it's completely turned into root. So we should use this method in the future when we switch identities.

(3) Execute only one root command

Su-C

(4) switch to another account

Su-l username

The way to use Login-shell.

Summarize:

(1) To complete the switch to the new user's environment, you want to use su-username/su-l username. To switch with Path/mail and so on.

(2) Use root to switch to any user without entering a password.

As can be seen from the above, Su to root is the root of the password, this is not safe, so with sudo.

Two. Sudo

Compared to the execution of Su,sudo, as long as their own password, or even no password. Only users who are set within/etc/sudoers can use Sudo,sudo by default, only root can be used. So if you want to use sudo for other accounts, you first need to use ROOT to modify the Sudoer file.

Because the sudoers file has certain rules, if the modification error is problematic, Root uses visodu to modify it so that when you leave Visodu, the system checks to see if the syntax is correct.

This is only for the time being used, and later can be consulted.

(1) Single user can execute root all commands with sudoers file syntax

In fact, Visudo only uses Vim to read the/etc/sudoers to make changes, we just add the following line:

(2) command operation with limited system

(3) How sudo is paired with Su

  

Chapter14:linux account Management (1) Identity switch

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.