#author("2021-05-11T13:58:04+00:00","","") #author("2021-05-11T13:58:30+00:00","","") #topicpath //////////////////////////////////////////////////////////////////////////////// * 目次 [#te6b26f4] #contents(); //////////////////////////////////////////////////////////////////////////////// * sudo [#fe55360e] //============================================================================== ** 設定 [#i64dfb0e] - 設定ファイル /etc/sudosers - 設定方法 + 設定は、 visudo コマンドで実行する。/etc/sudosers は以下のような記載となっている。 ------------------------------------------------------------------ # # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d ------------------------------------------------------------------ + ユーザに対する権限の設定を行う -- 書式 <user> ALL=(ALL:ALL) ALL -- 書式の内容 |~field |~description | |<user> |sudo を実行可とするユーザのID。&br;グループを設定する場合は "%"を先頭につける。&br;tty3 のように tty も指定出来る。 | |ALL= |ホストに対する許可(普通は ALL でよい) | |(ALL) |sudo されるユーザ名(ALL ならば全てのユーザ権限、つまり root 権限を使うことが出来る。&br;指定したユーザ<changed>に切り替えたい場合は (<changed>) のように記載する) | |ALL |利用出来るコマンドの制限(ALL は括弧で括ったユーザの使える全てのコマンドを利用出来る) | + 保存して終了する。 //============================================================================== ** sudo のコマンドラインオプション [#paffb131] - <command> -- root 権限で指定したコマンドを実行する - -s -- exit するまで root 権限のままでいられる - -u <user-id> <command or -s> -- 指定した user のユーザ権限でコマンド実行( -s の場合は exit するまでそのユーザ権限のままでいられる)