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.