Linux User Switching Su sudo__linux

Source: Internet
Author: User
1,su Command (su is switch user, which is shorthand for switching users)

Format: Su-l USERNAME (-L-Login, abbreviated for landing)

If you do not specify username (username), the default is root, so the command to switch to root is: su-root or direct Su-

Use SU to switch users need to know the corresponding user's login password


2:su-the difference from Su

Su-username switch to a new user's working environment after switching users

SU username switch users, do not change the original user's working directory, and other environment variables directory


3,sudo command


sudo is a privilege management mechanism that relies on/etc/sudoers, which defines which users are empowered to perform administrative commands as administrators;

Format:sudo-u USERNAME COMMAND

When a normal user executes a command by sudo to root, the-uusername behind sudo can be omitted, that is, the sudo COMMAND means sudo is executed by the root user


The difference between 5,sudo and Su

Use SU to switch users need to know the corresponding user login password, where switch to root user identity, need to understand the root user login password. As root administrator, how to authorize other ordinary users, without the need to know the root password in the case, to perform the command operation root permissions. Sudo can now be used.


4,sudoers file

The sudo configuration file is:/etc/sudoers.

The sudoers file allows you to specify that users can run various commands as root if they do not need to know the root user's login password. This file must use the Visudo command to edit the configuration. (The Visudo command can provide basic sanitychecks and check for parse errors, which provides quick correctness validation checks, as well as syntax checking capabilities)

View the Sudores file, which has a row like the following, which defines the Allow root user to log in from any host, using sudo to switch to any user's identity, and execute all commands.




Look at the sudoers file, which has two lines, as shown below, that define the configuration that groups can use the sudo command.




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.