日期:2014-05-16  浏览次数:20592 次

linux 添加新用户并赋予sudo执行权限

1、添加新用户

adduser xyw-Eliot

2、设置密码

passwd xyw-Eliot

根据提示输入3次密码

在使用sudo命令的时候,会提示:sudo:must be setuid root 错误,就是无法使用sudo命令,解决方法:

使用su ,进入root用户下,执行:

chown root:root /usr/bin/sudo

chmod /usr/bin/sudo

再次使用sudo命令,发现提示:xyw-Eliot is not in the sudoers file. This incident will be reported.说明xyw-Eliot还是没有权限使用sudo,解决方法:

1)输入su,进入root模式。

2)添加写文件权限:chmod u+w /etc/sudoers

3)编辑文件 /etc/sudoers,即 vim chmod u+w /etc/sudoers,找到"root ALL=(ALL) ALL"这行,在下面添加:xyw-Eliot ALL=(ALL) ALL

根据实际情况将xyw-Eliot换成你的用户名。保存退出。

4)撤销写文件权限:chmod u-w /etc/sudoers