30

Google hits inform that sudo means super user do as I read this SO post here.

I just wanted to verify that when I do

sudo node my_node_program

that I am running the program as the root user.

Does

superuser === root

After some research, Apple states that root is a superuser, which implies that superuser is a group and root is a user in the group.

See support.apple.com.

Seems like everyone is blurring the terms / concepts together.

  • 23
    sudo means switch user and do. It's just that, like su, it defaults to the root user. – OrangeDog May 20 at 11:08
  • 4
    @OrangeDog You just made that up though. su was always super-user and the documentation of sudo from 1993 simply says execute a command as the superuser. You can "backronym" as much as you want, but the sources don't lie. – pipe May 20 at 11:47
  • 24
    @pipe In AT&T Unix V7 (1979) the source says "substitute user". Later (and forked) versions changed it to "switch user". The version you're looking at from 1993 obviously didn't get the memo. – OrangeDog May 20 at 12:02
  • 5
    @pipe Many manuals commonly refers to "substitute user" for su – Jean-Baptiste Yunès May 20 at 12:11
  • 6
    @pipe well in 1975 (UNIX V6) all it did was elevate to superuser. When they make it more generic, they changed the meaning accordingly. – OrangeDog May 20 at 12:24
40

Yes, as a general rule, root and superuser are the same; "root" is a/the name typically given to a user with full system privileges on a Unix type system.

It is technically possible for other users/accounts to have the same level of access. It's purely semantics, but I guess some people call these accounts "superuser accounts" (which describes the account type and access), while others call the accounts "root accounts", which refers to accounts that have the same access as root - i.e. everything.

BTW, SUDO does not mean super user

SUDO is a mechanism to elevate/change privileges. It is possible to use SUDO to elevate a normal account to superuser privileges, but it can also be used to provide more limited access, e.g. allowing a user to run stuff as another user, which is typically a lot more limited then superuser. (For example, a user might use sudo to run something as the web server user, which would allow them to access resources they normally don't have access to, but it would not allow them to modify security permissions or access stuff which only the root account/super user account should have access to.)

  • 23
    substitute user do would suit it better than super user do, in fact. – Xtreme Biker May 20 at 7:35
  • 24
    @XtremeBiker I always read sudo as switch user do. – oldherl May 20 at 10:07
  • "superuser" could also refer to natural persons who have access to the root account. – OrangeDog May 20 at 11:30
  • 1
    No matter what it stands for, let's all just agree it is pronounced sudo and not sudo. – user1717828 May 20 at 17:06
  • @user1717828 clearly it is "Sue-do" - just make sure you have a user "Sue" with all the necessary permissions. – Baldrickk May 21 at 8:48
19

Superuser is the generic term to refer to the user account used for system administration. That means that the superuser has the ability to perform privileged operations such as creating/deleting user accounts. Please note that the actual name and implementation of the superuser account vary between operating systems.

In Unix-like operating systems (macOS, GNU/Linux, BSD, etc.), the superuser is the account whose UID (user identifier) is zero, no matter how it is named. In most of these OSes, it's named root by convention.

So, while superuser and root can be used interchangeably in most Unix-like OSes, they don't hold the same meaning.

  • 1
    Superuser could also refer to a Windows administrator account – wjandrea May 20 at 14:14
12

"The superuser" is often the description of a role in the security model that grants all permissions.

Historically the login / username associated with the role of superuser is root on UNIX-like operating systems like MacOS (and for instance "Administrator" on MS Windows).

Is superuser the same as root?

Yes, for all intents and purposes running a program "as the superuser" or "as root" is the same and you will be able to do things you could not do as "regular" user (such as for instance starting services that listen to reserved ports in the 1-1024 range, creating new users and other system management tasks. )

I just wanted to verify that when I do

sudo node my_node_program

that I am running the program as the root user.

As the manual states (check with man sudo ) running sudo without specifying a user using the optional -u [username|#uid-number] argument, will default to running the command as root.

3

There are differences...

root is the username of a superuser, and is expected to be present in all unixes. root uid is 0, the uid of the superuser.

But there can be many other users with the uid 0, all of which will have superuser rights as well (what counts is the uid, in most cases, and not the username associated with it. the name in /etc/passwd mostly serves to allow ls, find etc to display a human readable name instead of an uid, and to allow some commands to accept a username instead of an uid (chown, etc)).

awk -F':' '($3 == 0)' /etc/passwd  # will list all superuser accounts. root, and maybe others

So no, root and superuser is not equivalent. root is the "main" superuser, but there can be others...

Additionnally, some groups give some "superuser rights" over some files/directories. Or you could have acls allowing more than the superuser to execute something (... but still limited to that user's uid, so it does not automaticcaly grant superuser rights, just may grant access to superuser reserved commands or directories, for exemple). And you could have some /etc/sudoers entries allowing some other logins to execute some commands (or ALL) as the superuser (this time with the superuser effective uid, and therefore rights)...

  • note that: checking a system for other "uid 0" entry is good to do ... each of those entries is in effect a superuser, and each have its own password ! (giving multiple degrees of password "weakness" for an attacker to exploit, if that attacker knows those other "uid 0" usernames) – Olivier Dulac May 20 at 14:10
  • 4
    Ot may be worth adding that there should ideally be a 1:1 mapping between uid and username - certainly it is technically possible to have multiple users with uid 0 and associated root access, but this messes up the ownership name mapping and is not good security practice. Requiring non-root login +sudo gives more traceability and accountability- especially in a distributed environment with remote loging. – davidgo May 20 at 19:45
  • @davidgo I agree 100% – Olivier Dulac May 20 at 20:10
  • 4
    @davidgo: It might not be good practice, but I think it's still the default practice on some BSDs to have an account named toor with uid 0... (Difference being shells, one has a convenient ksh/bash/zsh the other a guaranteed-to-work sh.) – grawity May 21 at 6:38
  • 1
    @grawity. I just learnt sonething. Seems like those BSDs have it backwards. – davidgo May 21 at 7:01
0

"superuser" was used to qualify a person that has privileges on a system. "root" is the common logname of the superuser in *NIX systems.

That guy is the superuser, his login is "root".

Now, these terms are frequently used interchangeably and harmlessly.

0

TL;DR

When you run sudo, you're changing the effective user and/or group ID of a process call. Sudo defaults to the root user, but can use other users and groups as well (see the -u flag, for example).

The root user is the system's default superuser, but the choice of name is a convention rather than a hardcoded requirement. Don't change it, though, unless you are a masochist.

UID 0 is a Built-in Superuser

You're looking at this backwards. Root is an instance of a superuser (e.g. a user with elevated system privileges), but there can be any number of superusers on a Linux or Unix system. root just happens to be the expected name of the user with a real ID of 0. That user ID (UID) is hardcoded into the kernel and receives special permissions on *nix systems.

The default superuser group (e.g. root on most Linux distros, wheel on most BSD derivatives) can contain other users too, which then have access to things with the relevant read, write, execute permissions set in the group bits of the mode. For example:

-rw-rw-r--  1 root  root  6804 Aug 17  2018 /etc/passwd

This file is readable and writable by the root user, as well as anyone in the root group.

Various utilities like sudo or SGID binaries can provide other users with an effective UID (EUID) or effective GID (EGID) that allows them to perform privileged operations. While not recommended, you can also have more than one user with the same UID, so anyone in /etc/passwd with a UID of 0 is effectively root as well, even if the account names are different. Some BSDs have historically included a toor user with a real UID of 0, along with the standard root user.

You can even rename your root account to something else, if you like. That's generally a bad idea because many scripts and utilities expect the first account with UID 0 to actually be named root, and often use the account's name instead of its UID or GID to set permissions. For example, the following lines are usually equivalent:

chown 0:0 /etc/passwd
chown root:root /etc/passwd

However, while the kernel doesn't care if you rename the root account to toor or even luser, you can generally expect things to break if you don't have your first superuser account named root with a real ID of 0. Think of it as a de facto portability standard, for all practical purposes.

The Default Superuser Group

Most Linux systems use root for the name of the default superuser group. User root is a member of this group. The group is usually assigned a group ID (GID) of 0, but this isn't enforced by the kernel.

On BSD-based systems like macOS, the default superuser group is generally wheel instead of root. This difference can crop up in cross-platform scripting, but isn't as likely to cause unpleasant surprises as a renamed root user.

0

The internet can be very misleading at times as this google search tells you that sudo stands for super user do. However this is not the case as you can use sudo to switch to other types of users.

root is an instance of a type of user colloquially known as a superuser. "Super" b.c. the user has a high level of access.

There can be many users of the type superuser and you can actually login with the name root in many nix systems.

The reason that people mistake sudo for super user do, is that root is the default user for sudo. You can see this effect by executing the line below.

sudo whoami

will return root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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