-1

I am curious why the super user command su is run and not super user do (sudo).

Thomas Dickey
  • 76,765
nerd7473
  • 193

2 Answers2

4

su and sudo are the two most common ways to run a program (possibly a shell) as another user (possibly root). They have the same effect, but they work very differently in terms of how they determine whether to allow the action:

  • su requires that either the source user is root, or the user demonstrate that they have access to the target account (typically by typing a password).
  • sudo requires pre-authorization: the combination of source user, target user and command must be declared in its configuration file.

su came first: it existed as far back as Unix V3 in 1973. Back then it only covered the case of becoming root (hence the name: super-user). sudo came a bit later in 1980, to add the possibility of defining complex authorization policies. Because su is older and simpler, it's a standard tool, available on all unix-like systems, while sudo, while a very common add-on, is often missing from default installations and embedded systems.

Debian defaults to su because it's part of the base system — under Linux, there's an su program both in GNU Coreutils (along with ls, cp, etc.) and in util-linux (along with mount, fdisk, taskset, etc.). Many system scripts that run as root use su to launch tasks as a system user. The sudo package is optional because you can run a system without it, it's an end-user tool, rarely used by other software.

In terms of security, see Which is the safest way to get root privileges: sudo, su or login?

  • At least on my system, su is neither in the coreutils nor in util-linux packages, but in login (which is part of the base system, so your main point is uneffected). – tarleb Aug 22 '15 at 08:16
  • Most common occurrence of a linux/unix install without sudo is on embedded systems where disk space is at an absolute premium. – Shadur-don't-feed-the-AI Aug 22 '15 at 09:48
1

Sudo is an additional program which may or may not be installed on a system. It's available as package sudo on Debian. Without more information on the specific situation/code you are referring to, the most likely answer is that sudo cannot be assumed to be installed, why su is required to be present as by the POSIX standard installed as part of Debians base system. Any script or tutorial striving for maximum portability will hence use su.

tarleb
  • 2,077