具体操作步骤
1.首先我们建立一个账户,设置密码
[root@VM_0_13_centos home]# useradd 123
[root@VM_0_13_centos home]# passwd 123
Changing password for user better407.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
2.运行visudo工具编辑/etc/sudoers 文件
[root@VM_0_13_centos /]# visudo##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS## Allows people in group wheel to run all commands #在此添加
# %wheel ALL=(ALL) ALL
123 ALL=(ALL) ALL
3.将123账户添加到root用户组
[root@VM_0_13_centos home]# usermod -aG root 123
4.执行到su命令切换到新建的用户123
[root@VM_0_13_centos /]# su 123
bash-4.1$ groups
123 root