原文:https://www.jianshu.com/p/5bf1fe9c6483
为用户配置sudo权限并加上免密配置。
① 使用su命令切换超级用户(root用户)
② 我们需要在sudoers配置文件中修改,所以先为该文件配置写权限:
chmod u+w /etc/sudoers // 给/etc下的sudoers文件加上write权限
③ 进入sudoers文件,加上对应用户的配置语句:
vi /etc/sudoers //进入文件后找到## Allows people in group wheel to run all commands
找到该句
## Allows people in group wheel to run all commands
在这里插入图片描述

④ 配置用户sudo免密权限。按i进入insert模式,在root    ALL=(ALL)       ALL下方加上:
[你需要配置的用户名] ALL = (ALL) ALL        //在sudo的时候需要输入密码
或 
[你需要配置的用户名] ALL = (ALL) NOPASSWD:ALL        //在sudo的时候不需输入密码
然后esc退出insert模式,按冒号后输入wq保存退出。

配置好后如图
![在这里插入图片描述](https://img-blog.csdnimg.cn/b9d6d41e26334c84a3871672579e01a6.png)

⑤ 为了安全考虑移除sudoers文件的写权限:
chmod u-w /etc/sudoers        //移除sudoers的写权限
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐