GNU/Linux >> Linux の 問題 >  >> Linux

Linux –`su-`と`su–login`の違いは何ですか?

suから のマニュアルページ:

For  backward  compatibility, su defaults to not change the current directory
and to only set the environment variables HOME and SHELL (plus USER and LOGNAME
if the target user is not root).  It is recommended to always use the 
--login option (instead of  its  shortcut -) to avoid side effects caused
by mixing environments.

...

-, -l, --login
    Start the shell as a login shell with an environment similar to a real login:

        o      clears all the environment variables except TERM

        o      initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH

        o      changes to the target user's home directory

        o      sets argv[0] of the shell to '-' in order to make the shell a login shell

-の間に違いがあるかどうかを判断するのは難しいです および--login (またはおそらく -l <​​/ code> )。つまり、マニュアルページには「ショートカットの代わりに-」と書かれていますが、これらのオプションはすべてグループ化されており、違いが存在する場合でも、その違いの説明は表示されません。

UPD 私は自分の問題を解決するはずの質問をチェックしました。問題は基本的にsuの違いについてです およびsu- 。そして、su-の違いについて質問しています およびsu--login 。いいえ、それはまったく解決しません。

承認された回答:

Debianの手動入力はより啓発的であるようです:

   -, -l, --login
       Provide an environment similar to what the user would expect had the user logged
       in directly.

       When - is used, it must be specified before any username. For portability it is
       recommended to use it as last option, before any username. The other forms (-l
       and --login) do not have this restriction.

Linux
  1. シェル変数と環境変数の使用法の違いは?

  2. Sudo Su –とSudo Su —の違いは何ですか?

  3. Linux – Reboot、Init 6、Shutdown -r Nowの違いは?

  1. 通常のユーザーとシステムユーザーの違いは何ですか?

  2. AwkのPrintとPrintfの違いは何ですか?

  3. Nohup とアンパサンドの違いは何ですか

  1. $(stuff)と `stuff`の違いは何ですか?

  2. bashの&>と>&の違いは何ですか?

  3. 「su -」と「su --login」の違いは何ですか?