-pまたは-mフラグを含むsuコマンド

-pまたは-mフラグを含むsuコマンド

次のsuコマンドの違いは何ですか?

su -m
su -p

どちらのフラグも現在の環境を保存するために使用されていることを知っていますが、違いがあるかどうかはわかりません。

ベストアンサー1

違いはありません。同じ振る舞いの別のオプションです。su同じ動作で、これらのオプションの1つを実装した他の以前のバージョンから来ることができます。

マニュアルページから:

 -m, -p, --preserve-environment
     Preserve the current environment, except for:

     $PATH
         reset according to the /etc/login.defs options ENV_PATH or
         ENV_SUPATH (see below);

     $IFS
         reset to “<space><tab><newline>”, if it was set.

     If the target user has a restricted shell, this option has no
     effect (unless su is called by root).

おすすめ記事