1, root下 usermod -a -G wheel userName, 重启或者注销
2,当前用户下: [kdb@localhost Desktop]$ sudo usermod -aG vboxsf $(whoami) 重启或注销。
3,可以显示。
方法一、直接修改/etc/sudoers文件
1. /etc/sudoers内容格式
# 用户myuser允许运行任何命令操作
myuser ALL=(ALL) ALL
# 用户组mygroup允许运行任何命令操作
%mygroup ALL=(ALL) ALL
2. 修改文件
root@centos-system$ vim /etc/sudoers
添加
myuser ALL=(ALL) ALL
方法二、将用户追加到sudo用户组
root@centos-system$ sudo usermod -a -G sudo userName
在 centos上可能会出现
usermod: group 'sudo' does not exist
因为centos默认没有sudo组,可以将你的用户指向wheel用户组, wheel用户组同样有sudo权限
所以在centos上可以使用如下命令添加用户组
root@centos-system$ sudo usermod -a -G wheel userName
操作后注销重新登录
修改后必须重新登录才生效,否则会报错
sunny is not in the sudoers file. This incident will be reported.
————————————————
版权声明:本文为优快云博主「二流小宝」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/sweettool/article/details/72731464
本文详细介绍了在CentOS系统中如何通过修改sudoers文件或用户组来配置sudo权限,包括将用户添加到wheel组以获得sudo权限的方法。
684

被折叠的 条评论
为什么被折叠?



