1、在root用户下创建新用户 如XXX
[root@localhost ~]# adduser XXX
2、为新用户XXX设置密码
[root@localhost ~]# passwd XXX
3、为新用户XXX授权
① 找到 sudoers 文件路径
[root@localhost ~]# whereis sudoers
② 为 sudoers 文件添加 w 权限
[root@localhost ~]# chmod -v u+w /etc/sudoers
③ 追加新用户XXX权限
[root@localhost ~]# vim /etc/sudoers
## Allow root to run any commands anywher
root ALL=(ALL) ALL
XXX ALL=(ALL) ALL #这个是新增的用户
④ :wq 保存退出 收回 sudoers 文件 w 权限
[root@localhost ~]# chmod -v u-w /etc/sudoers
4、通过新用户名跟密码登录即可