Skip to main content
added 17 characters in body
Source Link
Zim
  • 209
  • 3
  • 5

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix display manager or shell profile, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix display manager, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix display manager or shell profile, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

added 3 characters in body
Source Link
Zim
  • 209
  • 3
  • 5

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix init systemsdisplay manager, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix init systems, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix display manager, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

edited body
Source Link
Zim
  • 209
  • 3
  • 5

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix init systems, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su --login will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix init systems, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su --login will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

They are different in semantics.

Using su means you don't want the invoked process to be aware of the fact that you are not the real target user. The man page recommends always taking option su --login.

Using sudo means the opposite. sudo even sets a new environment variable SUDO_UID to tell the process who you really are.

BTW, su is adapted to ancient unix init systems, which set only a few number of environment variables (HOME, PATH, etc) before invoking the interactive shell. And su will reset those variables.

However modern init systems set much more environment variables. e.g. Linux PAM sets XDG_RUNTIME_DIR, which will not be reset by su. Hence, su --login cannot emulate a real login. See https://github.com/systemd/systemd/issues/7451#issuecomment-346787237

added 8 characters in body
Source Link
Zim
  • 209
  • 3
  • 5
Loading
Source Link
Zim
  • 209
  • 3
  • 5
Loading