我想在/ etc / sudoers文件中删除(uncommnet#)轮组,那么我应该使用什么样的Regex模式?
#cat /etc/sudoers
....
....
## Allows members of the 'sys' group to run networking,software,## service management apps and more.
# %sys ALL = NETWORKING,SOFTWARE,SERVICES,STORAGE,DELEGATING,PROCESSES,LOCATE,DRIVERS
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
....
....
我想从以下行中删除#.
...
# %wheel ALL=(ALL) NOPASSWD: ALL
...
最佳答案
您不应该使用任何类型的脚本编辑/ etc / sudoers文件.这是visudo命令的原因.对sudoers文件的编辑应该是罕见的并且控制得很好.
话虽这么说,如果你的visudo命令的编辑器是vi,你可以运行类似:%s / ^#%wheel /%wheel /来取消注释以%wheel开头的所有行.
或者,如果您认为有必要:
sudo sed --in-place 's/^#\s*\(%wheel\s\+ALL=(ALL)\s\+NOPASSWD:\s\+ALL\)/\1/' /etc/sudoers
首先运行它而不使用–in-place来检查输出.需要您自担风险使用它.