最終更新:2017-07-04 (火) 18:05:24 (2481d)
Linux/etc/sudoers
例
%adm ALL=(ALL) ALL
- %adm 対象となるグループまたはユーザー。グループの場合、「%」を付けユーザーの場合は、何もつけない。
- ALL = ホストに対する許可。ローカルネットワークのみの場合など、ここで設定します。
- (ALL) 指定されたユーザー等の権限 (ALLの場合ルート権限となる)
- ALL 利用できるコマンド。(ALLの場合、カッコで括ったユーザの使える全てのコマンド)
wheelグループにsudo権限を与える場合
%wheel ALL=(ALL) ALL
userにsudo権限を与える場合
user ALL=(ALL) ALL
shutdownだけ許可
user ALL = (root) /sbin/shutdown
パスワード無し
user ALL = (ALL)NOPASSWD: ALL <username> ALL=NOPASSWD: ALL
特定のコマンドのみ
hoge ALL=NOPASSWD: /sbin/shutdown
- sudoでNOPASSWORDが効かない場合、設定をファイルの一番最後に設定を書けば解決します。
編集のためのコマンド
Ubuntu
# /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # See the man page for details on how to write a sudoers file. # Defaults env_reset # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL) ALL # Allow members of group sudo to execute any command # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL # #includedir /etc/sudoers.d # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL
- adminとsudoグループがsudoを許可されているので
usedmod -g admin user
か
usedmod -g sudo user
Debian
# /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # See the man page for details on how to write a sudoers file. # Defaults env_reset # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL) ALL # Allow members of group sudo to execute any command # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL # #includedir /etc/sudoers.d
- sudoグループがsudoを許可されているので
usedmod -g sudo user