Linux – What’s the difference between `su -` and `su –login`

linuxsu

From su's man page:

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

It's hard to tell if there's any difference between - and --login (or supposedly just -l). Namely, the man page says "instead of its shortcut -", but all these options are grouped together, and I don't see an explanation of the difference, if it exists at all.

UPD I checked the question, which is supposed to solve my problem. The question is basically about difference between su and su -. And I'm asking about difference between su - and su --login. So no, it doesn't solve it at all.

Best Answer

Debian's manual entry seems to be more enlightening:

   -, -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.
Related Question