注意需要在root权限下操作,非root用户操作时命令添加sudo
1、建立用户
[root@host-192-168-1-177 ~]# adduser testUser
2、设置密码
[root@host-192-168-1-177 ~]# passwd testUserChanging password for user testUser.New password: Retype new password: passwd: all authentication tokens updated successfully.
3、赋予管理员权限
修改文件/etc/sudoers 在root ALL=(ALL) ALL 下添加一行
testUser ALL=(ALL) ALL
[root@host-192-168-1-177 ~]# vi /etc/sudoers
修改完毕后使用wq!命令保存
4、测试
使用testUser 登陆后输入sudo su 看否切换到root 账户