Ubuntu:为普通用户赋予sudo权限

sudo功能的配置文件一般在这里:/etc/sudoers,可以使用visudo编辑,好处是如果规则写的不符合要求能提示你,坏处是调出的是nano编辑器。而且/etc/sudoers的配置文件的注释里也说明了,不建议直接修改/etc/sudoers,而是通过在/etc/sudoers.d/文件夹中新增文件来完成配置。

Please consider adding local content in /etc/sudoers.d/ instead of directly modifying this file.

新增的文件就用vi编辑就可以了,比如说要为mantou增加sudo权限,就增加一个文件,文件名无所谓,内容是:

mantou ALL=(ALL) ALL

保存,退出vi

然后需要把这个文件权限设置为400:chmod 400 mantou

再用mantou用户登录后就可以使用sudo权限了。