在/etc/sudoers中同时使用NOPASSWD和sudoedit的语法是什么?我试过这个:
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file但我还是会被提示输入密码。
发布于 2013-10-25 15:25:37
你应该能做任何这些。
一旦有了这些定义中的一个,就可以像这样调用它:
sudoedit /path/to/file您不需要使用像这样的sudo命令前缀来调用它:
sudo sudoedit /pat/to/file它自动处理sudo。它等同于sudo -e /pat/to/file,它将调用具有提升权限的编辑器。
摘自sudo/sudo编辑手册页
-e The -e (edit) option indicates that, instead of running a command,
the user wishes to edit one or more files. In lieu of a command, the
string "sudoedit" is used when consulting the sudoers file. If the
user is authorized by sudoers the following steps are taken:
1. Temporary copies are made of the files to be edited with the
owner set to the invoking user.
2. The editor specified by the SUDO_EDITOR, VISUAL or EDITOR
environment variables is run to edit the temporary files.
If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first
program listed in the editor sudoers variable is used.
3. If they have been modified, the temporary files are copied
back to their original location and the temporary versions
are removed.您可以通过设置上面提到的一个环境变量来覆盖编辑器,例如,设置要使用的编辑器的名称,例如vim或gedit。
https://unix.stackexchange.com/questions/97578
复制相似问题