su given su -, sudo specific ward separately

"sudo" , "su" , "su - " 区别;

A, sudo is a rights management mechanism, depending on the / etc / sudoers, which defines which users can authorize what kind of management command as an administrator can perform;

Format: 
sudo -u USERNAME the COMMAND

By default, the system has only the root user can execute sudo command. It requires root user by using the visudo command to edit the sudo configuration file / etc / sudoers, can authorize other ordinary users to run sudo command.

Two, su to switch user, i.e. the user's short switching.

Format into two: 
su the -l USERNAME (- L to login, that is short for landing) 
su USERNAME

If you do not specify a USERNAME (user name), the default is the root,

SU USERNAME, and su - differs USERNAME follows:
 . 1, su - USERNAME after the handover user, and switch to the new user's work environment. 
2, after su USERNAME switch user, do not change the original user's working directory, and other environment variable.

Three, su -, when su -l command or su --login change of identity, and also to change the working directory, and HOME, SHELL, USER, LOGNAME. In addition, the PATH variable will change.

"Su" and "su -" to switch biggest change is a switch environment variable.

With the su - command to convert the default root user.

So switch to the identity of the root of the order shall be: su -root  or  su - , su root  , or  su .

Rather than "su command" with the parameter does not change the current working directory and HOME, SHELL, USER, LOGNAME. Just have root privileges only.

Guess you like

Origin www.cnblogs.com/sharesdk/p/11447431.html