root授权给普通用户具有的权限

visudo

用户    机器=(极权那个角色的权利)

root    ALL=(ALL)       ALL

stephen ALL=(ALL)       /usr/sbin/useradd,/usr/sbin/userdel


[stephen@52game ~]$ sudo /usr/sbin/useradd kkk

[sudo] password for stephen:

Sorry, try again.

[sudo] password for stephen:

[stephen@52game ~]$ id kkk

uid=501(kkk) gid=501(kkk) 组=501(kkk)


[stephen@52game ~]$ sudo /usr/sbin/useradd 380233718

[stephen@52game ~]$ id 380233718

uid=502(380233718) gid=502(380233718) 组=502(380233718)

[stephen@52game ~]$


注意:sudo是钦差大臣,不能少,不能修改修改rooot。


皇帝的太子

leader  ALL=(ALL)       ALL

[root@52game ~]# useradd leader

[root@52game ~]# passwd leader

不用告诉leader root密码,可以切换到root


[root@52game ~]# su - leader

[leader@52game ~]$ su -

密码:


[leader@52game ~]$ sudo su -


We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:


   #1) Respect the privacy of others.

   #2) Think before you type.

   #3) With great power comes great responsibility.


[sudo] password for leader:

[root@52game ~]#

查询自己权限

sudo -l


管理员用户切换不需要密码

stephen ALL=(ALL)       NOPASSWD:ALL

[root@52game ~]# su - stephen

[stephen@52game ~]$ su -

密码:

[stephen@52game ~]$ sudo su -

[root@52game ~]#


立即使环境变量生效

. .bash_profile

source .bash_profile

你可能感兴趣的:(用户,角色)