`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

只是简写...

相关内容