回答:
これは通常、のsecure_pathオプションによって設定されます/etc/sudoers。からman sudoers:
secure_path Path used for every command run from sudo. If you don't
trust the people running sudo to have a sane PATH environ‐
ment variable you may want to use this. Another use is if
you want to have the “root path” be separate from the “user
path”. Users in the group specified by the exempt_group
option are not affected by secure_path. This option is not
set by default.
デフォルト$PATHにないコマンドを実行するには、次のいずれかを実行できます
完全なパスを使用しsudo ~/bin/my-commandます。または
コマンドを含むディレクトリをに追加しsecure_pathます。sudo visudoセキュアパス行を実行および編集します。
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/youruser/bin/"
ファイルを保存すると、次に実行するsudoときに、ディレクトリ~/binがその.exeになります$PATH。