「sudo env」と「sudo -i env」は異なる結果を表示します。

「sudo env」と「sudo -i env」は異なる結果を表示します。

サーバーでsudo env | grep PATHコマンドを実行すると、sudo -s env | grep PATH最初の2つのコマンドは同じ結果を表示します。sudo -i env | grep PATH

ただし、最後のエントリはsudo -i env | grep PATH異なるPATH値を示しています。

sudosudo -ssudo -iコマンドが同じPATH変数を持つのはなぜですか?

CentOS 7.8を使用しています。

すべてのコメント、リンクありがとうございます!

ベストアンサー1

sudoコマンドが原因で発生する可能性があります。変数をどのように拡張/定義しますかpath?ローカルユーザーに.profile?入力したばかりのsudo -iルートsudo -sになるので、次のように使用します.profileman sudo

-i, --login: Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile, .bash_profile or .login will be read by the shell.
-s, --shell: Run the shell specified by the SHELL environment variable if it is set or the shell specified by the invoking user's password database entry.

おすすめ記事