CentOS7 添加新用户并授权 root 权限

参考文章:CentOS 7中添加一个新用户并授权

# root 用户操作
$ 普通用户操作

创建用户

# adduser USERNAME
# passwd USERNAME (输入密码)

授权 root 权限

sudo 命令的授权管理是在sudoers文件里的。查看 sudoers 位置:
# whereis sudoers
查看 sudoers 的读写权限:
# ls -l /etc/sudoers
如果 sudoers 没有写权限则添加:
# chmod -v u+w /etc/sudoers
修改 sudoers:
# vim /etc/sudoers

找到 ## Allow root to run any commands anywher ,修改如下:
root ALL=(ALL) ALL
USERNAME ALL=(ALL) ALL # 这个是新增的用户

回收 sudoers 写权限:
# chmod -v u-w /etc/sudoers

使用$ sudo su命令,输入密码切换 root 用户

posted @ 2019-09-12 10:29  catyuang  阅读(8110)  评论(0编辑  收藏  举报