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

- 76,765

- 193
-
1Run where and when? – tarleb Aug 21 '15 at 21:57
-
Why was this down voted? – nerd7473 Sep 05 '15 at 20:56
2 Answers
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?

- 829,060
-
At least on my system,
su
is neither in thecoreutils
nor inutil-linux
packages, but inlogin
(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
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
.

- 2,077
-
1
-
@Gilles Had too look it up again, and you are right. I stand corrected. Funny story: if one googles "su posix", one of the first hits is a SO answers you gave, stating that "If it's POSIX you want, then su is your only option". I'm confused. – tarleb Aug 22 '15 at 08:04
-
This answered it... it is an additional program not in the system yet... – nerd7473 Sep 05 '15 at 20:58