Was ist der Unterschied zwischen „su -“ und „su --login“?

Was ist der Unterschied zwischen „su -“ und „su --login“?

Aussu's Manpage:

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

Es ist schwer zu sagen, ob es einen Unterschied zwischen -und gibt --login(oder angeblich nur -l). Die Manpage sagt nämlich „anstelle der Abkürzung -“, aber alle diese Optionen sind zusammengefasst, und ich sehe keine Erklärung für den Unterschied, falls es ihn überhaupt gibt.

UPDIch habe die Frage überprüft, dielöse mein Problem. Die Frage betrifft im Wesentlichen den Unterschied zwischen suund su -. Und ich frage nach dem Unterschied zwischen su -und su --login. Also nein, das löst das Problem überhaupt nicht.

Antwort1

Der Handbucheintrag von Debian scheint aufschlussreicher zu sein:

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

Antwort2

es gibt keinen Unterschied, es ist wie Laufen;

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

nur eine Abkürzung...

verwandte Informationen