55

Where did the term "superuser" originate? Is it a shortening of "supervisory user", or is it just an indicator of the level of power one such user holds in a system?

  • I am curious why superuser.com is named superuser. Is it the same connection? Does it come from Unix and the super-user from that operating system? – Corporate Geek Feb 1 '18 at 10:09
55

Where did the term "superuser" originate?

su allows one to become the super--user, who has all sorts of marvelous powers.

From the First Edition Unix su man page:

        11/3/71                                                        SU (I)


NAME              su -- become privileged user

SYNOPSIS          su password

DESCRIPTION       su allows one to become the super--user, who has all sorts
                  of marvelous powers. In order for su to do its magic, the
                  user must pass as an argument a password. If the password
                  is correct, su will execute the shell with the UID set to
                  that of the super--user. To restore normal UID privileges,
                  type an end--of--file to the super--user shell

FILES

SEE ALSO          shell

DIAGNOSTICS       "Sorry" if password is wrong

BUGS

OWNER             dmr, ken

Source minnie.tuhs.org/UnixTree/V5/usr/source/s2/su.c.html

su is used on Unix systems to change user, and is commonly used to run commands as the root user.

And ... read on

I had another foundation shaking moment with the meaning of "su". I found some old Unix source code, where su.c was available. Curious, I looked at the source. What did I find?

/* su -- become super-user */

char    password[100];
char    pwbuf[100];
int ttybuf[3];
main()
{
    register char *p, *q;
    extern fin;

    if(getpw(0, pwbuf))
        goto badpw;
    (&fin)[1] = 0;
    p = pwbuf;
    while(*p != ':')
        if(*p++ == '\0')
            goto badpw;
    if(*++p == ':')
        goto ok;
    gtty(0, ttybuf);
    ttybuf[2] =& ~010;
    stty(0, ttybuf);
    printf("password: ");
    q = password;
    while((*q = getchar()) != '\n')
        if(*q++ == '\0')
            return;
    *q = '\0';
    ttybuf[2] =| 010;
    stty(0, ttybuf);
    printf("\n");
    q = crypt(password);
    while(*q++ == *p++);
    if(*--q == '\0' && *--p == ':')
        goto ok;
    goto error;

badpw:
    printf("bad password file\n");
ok:
    setuid(0);
    execl("/bin/sh", "-", 0);
    printf("cannot execute shell\n");
error:
    printf("sorry\n");
}

What is the first comment in that C file?

/* su -- become super-user */

su was written to only change to the root user on the system. It wasn't designed to switch to any other user that has an account. "su" meant "super-user". I need to sit down for a second.

The code above comes from the fifth edition of Unix by Dennis Ritchie and Ken Thompson. If you know your Unix history, it really wasn't until the sixth edition that things really started taking off for the Unix world. So, it's safe to say that most, if not all, of the code in the fifth edition and prior were written by Dennis and Ken themselves. Fifth edition Unix released in 1975, so it doesn't get much more authoritative than that.

Source Aaron Toponce : The Meaning of 'su'


Further Reading

36

OED (paywalled) gives the following etymology:

super- prefix + user n.

The earliest example that they list is from K. Thompson & D. M. Ritchie (1971): "Unix Programmer's Man.":

Only the super-user may invoke this command.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.