如何从脚本中编辑/etc/sudoers? [英] How do I edit /etc/sudoers from a script?
本文介绍了如何从脚本中编辑/etc/sudoers?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从脚本中编辑/etc/sudoers
,以从白名单中添加/删除内容.
I need to edit /etc/sudoers
from a script to add/remove stuff from white lists.
假设我有一个可以在普通文件上运行的命令,如何将其应用于/etc/sudoers
?
Assuming I have a command that would work on a normal file, how could I apply it to /etc/sudoers
?
我可以复制和修改它,然后让visudo
用修改后的副本替换原件吗?通过在$EDITOR
中提供我自己的脚本?
Can I copy and modify it, then have visudo
replace the original with the modified copy? By providing my own script in $EDITOR
?
还是可以只使用相同的锁和cp
?
Or can I just use the same locks and cp
?
问题更多是关于潜在问题,而不仅仅是找到有用的东西.
The question is more about potential issues than about just finding something that works.
推荐答案
旧线程,但是:
echo 'foobar ALL=(ALL:ALL) ALL' | sudo EDITOR='tee -a' visudo
这篇关于如何从脚本中编辑/etc/sudoers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文