
/etc/sudoersでNOPASSWDとsudoeditを一緒に使用する構文は何ですか?私はこれを試しました:
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
ただし、まだパスワードの入力を求められます。
答え1
sudoersファイル
あなたはこれらのいずれかを行うことができなければなりません。
たとえば、
john ALL=(ALL) NOPASSWD: sudoedit
またはこれ:
john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
最後に、次のようにすることもできます。
Cmnd_Alias SOMECMD = sudoedit /path/to/file john ALL=(ALL) NOPASSWD: SOMECMD
これらの定義の1つがある場合は、次のように呼び出すことができます。
sudoedit /path/to/file
詳細
sudo
呼び出すために次のコマンドプレフィックスを使用する必要はありません。
sudo sudoedit /pat/to/file
自動的に処理されますsudo
。これはsudo -e /pat/to/file
、高い権限でエディタを呼び出すのと同じです。
sudo/sudoeditのマニュアルページから
-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
。