
(環境で?)するのとどんな違いがあるのか気になります。
sudo su - user
そして
sudo -iu user
私が知っている限り:sudo su - userを使用してユーザーとして新しいシェルを開くと、ダッシュはユーザーの環境変数を提供し(sudo su userはそうではありません)、sudo -iu userを使用します(-uは正しいユーザーを意味します) . - i 「初期ログインシミュレーション」を意味します。
では、違いは何ですか?
1つ目は、ユーザーがrootとしてsuを実行できるようにすることに加えて、2つ目は、ユーザーがbashをユーザーとして実行できるように要求します。
ありがとうございます!
答え1
これは、sudoのマニュアルページの「-i」オプションについて話すものです。
-i The -i (simulate initial login) option runs the shell specified in
the passwd(5) entry of the user that the command is being run as.
The command name argument given to the shell begins with a `-' to
tell the shell to run as a login shell. sudo attempts to change to
that user's home directory before running the shell. It also ini-
tializes the environment, leaving TERM unchanged, setting HOME,
SHELL, USER, LOGNAME, and PATH, and unsetting all other environment
variables. Note that because the shell to use is determined before
the sudoers file is parsed, a runas_default setting in sudoers will
specify the user to run the shell as but will not affect which
shell is actually run.
これは、基本的に参照されるユーザーのシェルをエミュレートしていることを示しています。一部ユーザーが直接ログインすると予想される状況は、まったく同じではない可能性があります。こんな質問をしたら」何「私の考えはわかりません。しかし、sudo su - user
そのコマンドを使用すると、参照されているユーザーの設定で新しいシェルプロセスを開始すると問題は発生しません。場合によっては、両方のコマンドを使用できます。同じ環境ですが、他の環境では違いが発生する可能性があると思います。