sudo 设置普通用户具有root权限
1.添加test用户,并对其设置密码。
[root@hadoop101 ~]#useradd test
[root@hadoop101 ~]#passwd test
2.修改配置文件
[root@hadoop101 ~]#vi /etc/sudoers
修改 /etc/sudoers 文件,找到下面一行(91行),在root下面添加一行,如下所示:
Allow root to run any commands anywhere
root ALL=(ALL) ALL
test ALL=(ALL) ALL
或者配置成采用sudo命令时,不需要输入密码
Allow root to run any commands anywhere
root ALL=(ALL) ALL
test ALL=(ALL) NOPASSWD:ALL
修改完毕,现在可以用test帐号登录,然后用命令 sudo ,即可获得root权限进行操作。