実行するコマンドを印刷するようにsudoを設定できますか?

実行するコマンドを印刷するようにsudoを設定できますか?

sudo昇格した権限でコマンドを実行することを承認する前に、呼び出しスクリプトを実行しているか、sudoコマンドで変数/エスケープ/サブシェルを使用しているかにかかわらず、コマンドが理解されていることを確認したいと思います。

私のユーザーパスワードを尋ねるときにsudo実行するコマンドの印刷を要求する方法はありますか?

このような:

$ sudo some command with parameters
sudo: about to run ``some command with parameters``
Password:

ベストアンサー1

sudo -l <somecommand> <someparameters> 

コマンドがセキュリティポリシーによって指定され、許可されている場合、コマンドへの完全なパスはコマンドライン引数とともに表示されます。

これはから抜粋したものです。man sudo

-l, --list  If no command is specified, list the allowed (and forbidden) commands for the invoking user (or the user speci‐
                 fied by the -U option) on the current host.  A longer list format is used if this option is specified multiple
                 times and the security policy supports a verbose output format.

                 If a command is specified and is permitted by the security policy, the fully-qualified path to the command is
                 displayed along with any command line arguments.  If command is specified but not allowed, sudo will exit with
                 a status value of 1.

おすすめ記事