首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sudoers -如何同时使用NOPASSWD和sudoedit?

sudoers -如何同时使用NOPASSWD和sudoedit?
EN

Unix & Linux用户
提问于 2013-10-25 14:56:02
回答 1查看 12.1K关注 0票数 2

在/etc/sudoers中同时使用NOPASSWD和sudoedit的语法是什么?我试过这个:

代码语言:javascript
复制
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file

但我还是会被提示输入密码。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2013-10-25 15:25:37

sudoers文件

你应该能做任何这些。

  1. 如: john ALL=(ALL) NOPASSWD: sudo编辑
  2. 或者这个: john ALL=(ALL) NOPASSWD: sudo编辑/path/to/file
  3. 最后,您也可以这样做: Cmnd_Alias SOMECMD =sudo编辑/path/to/file john ALL=(ALL) NOPASSWD: SOMECMD

一旦有了这些定义中的一个,就可以像这样调用它:

代码语言:javascript
复制
sudoedit /path/to/file

详细信息

您不需要使用像这样的sudo命令前缀来调用它:

代码语言:javascript
复制
sudo sudoedit /pat/to/file

它自动处理sudo。它等同于sudo -e /pat/to/file,它将调用具有提升权限的编辑器。

摘自sudo/sudo编辑手册页

代码语言:javascript
复制
-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.

您可以通过设置上面提到的一个环境变量来覆盖编辑器,例如,设置要使用的编辑器的名称,例如vimgedit

票数 3
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/97578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档