【Linux】赋予root权限

发布时间 2023-09-14 16:13:02作者: 幸福在靠近

1、创建普通用户并将wheel群添加进次要组群

[root@centos83 mysql]# visudo
// 如果 %wheel 前面有 # ,删除它,然后保存后退出
## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

[root@centos83 mysql]# useradd -G wheel suhai	//添加新用户并设置次要组群为管理群wheel
[root@centos83 mysql]# passwd suhai
//此时用户suhai便拥有了管理员权限,使用sudo+命令即可

 2、查看群组下有那些管理员

[root@centos83 mysql]# cat /etc/group |grep wheel
wheel:x:10:suhai

 3、从wheel组删除用户

gpasswd -d suhai wheel
其中,gpasswd 是用于管理用户组的命令,-d 参数表示删除用户,suhai 是要删除的用户名,wheel 是要删除的组名。

 3、删除用户

 userdel -r suhai