`su -` 和 `su --login` 之間有什麼區別?

`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)。也就是說,手冊頁顯示“而不是其快捷方式 -”,但所有這些選項都組合在一起,並且我看不到差異的解釋(如果存在的話)。

UPD我檢查了這個問題,應該是解決我的問題。問題基本上是關於su和之間的區別su -。我問的是su -和之間的區別su --login。所以不,它根本不能解決問題。

答案1

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.

答案2

沒有什麼差別,就像跑步一樣;

echo bob | grep -v bob
echo bob | grep --invert-match bob

只是簡寫...

相關內容