Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems identify a user by a value called a user identifier, often abbreviated to user ID or UID. The UID, along with the group identifier (GID) and other access control criteria, is used to determine which system resources a user can access. The
password file maps textual
user names to UIDs. UIDs are stored in the
inode
The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attribu ...
s of the
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one lar ...
, running
processes
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
*Business process, activities that produce a specific se ...
,
tar
Tar is a dark brown or black viscosity, viscous liquid of hydrocarbons and free carbon, obtained from a wide variety of organic matter, organic materials through destructive distillation. Tar can be produced from coal, wood, petroleum, or peat. ...
archives, and the now-obsolete
Network Information Service
The Network Information Service, or NIS (originally called Yellow Pages or YP), is a client–server directory service protocol for distributing system configuration data such as user and host names between computers on a computer network. Su ...
. In
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
-compliant environments, the command-line command
id
gives the current user's UID, as well as more information such as the user name, primary user group and group identifier (GID).
Process attributes
The POSIX standard introduced three different UID fields into the process descriptor table, to allow privileged processes to take on different roles dynamically:
Effective user ID
The effective UID (
euid
) of a process is used for most access checks. It is also used as the owner for files created by that process. The effective GID (
egid
) of a process also affects access control and may also affect file creation, depending on the semantics of the specific kernel implementation in use and possibly the mount options used. According to BSD Unix semantics, the group ownership given to a newly created file is unconditionally inherited from the group ownership of the directory in which it is created. According to
AT&T
AT&T Inc. is an American multinational telecommunications holding company headquartered at Whitacre Tower in Downtown Dallas, Texas. It is the world's largest telecommunications company by revenue and the third largest provider of mobile tel ...
UNIX System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
semantics (also adopted by Linux variants), a newly created file is normally given the group ownership specified by the
egid
of the process that creates the file. Most filesystems implement a method to select whether BSD or AT&T semantics should be used regarding group ownership of a newly created file; BSD semantics are selected for specific directories when the S_ISGID (s-gid) permission is set.
File system user ID
Linux also has a file system user ID (
fsuid
) which is used explicitly for access control to the file system. It matches the
euid
unless explicitly set otherwise. It may be root's user ID only if
ruid
,
suid
, or
euid
is root. Whenever the
euid
is changed, the change is propagated to the
fsuid
.
The intent of
fsuid
is to permit programs (e.g., the
NFS server) to limit themselves to the file system rights of some given
uid
without giving that
uid
permission to send them signals. Since kernel 2.0, the existence of
fsuid
is no longer necessary because Linux adheres to
SUSv3 rules for sending signals, but
fsuid
remains for compatibility reasons.
[Kerrisk, Michael. ''The Linux Programming Interface''. No Starch Press, 2010, p. 171.]
Saved user ID
The saved user ID (
suid
) is used when a program running with elevated privileges needs to do some unprivileged work temporarily; changing
euid
from a privileged value (typically
0
) to some unprivileged value (anything other than the privileged value) causes the privileged value to be stored in
suid
. Later, a program's
euid
can be set back to the value stored in
suid
, so that elevated privileges can be restored; an unprivileged process may set its
euid
to one of only three values: the value of
ruid
, the value of
suid
, or the value of
euid
.
Real user ID
The real UID (
ruid
) and real GID (
rgid
) identify the real owner of the process and affect the permissions for sending signals. A process without superuser privileges may signal another process only if the sender's
ruid
or
euid
matches receiver's
ruid
or
suid
. Because a child process inherits its credentials from its parent, a child and parent may signal each other.
Conventions
Type
POSIX requires the UID to be an integer type. Most Unix-like operating systems represent the UID as an unsigned integer. The size of UID values varies amongst different systems; some UNIX OS's used 15-bit values, allowing values up to 32767, while others such as
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
(before version 2.4) supported
16-bit
16-bit microcomputers are microcomputers that use 16-bit microprocessors.
A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two mos ...
UIDs, making 65536 unique IDs possible. The majority of modern Unix-like systems (e.g., Solaris-2.0 in 1990, Linux 2.4 in 2001) have switched to
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in 32- bit units. Compared to smaller bit widths, 32-bit computers can perform large calcula ...
UIDs, allowing 4,294,967,296 (2
32) unique IDs.
Reserved ranges
The
Linux Standard Base Core Specification specifies that UID values in the range 0 to 99 should be statically allocated by the system, and shall not be created by applications, while UIDs from 100 to 499 should be reserved for dynamic allocation by system administrators and post install scripts.
Debian Linux not only reserves the range 100–999 for dynamically allocated system users and groups, but also centrally and statically allocates users and groups in the range 60000-64999 and further reserves the range 65000–65533.
Systemd defines a number of special UID ranges, including
* 60001-60513: UIDs for home directories managed by systemd-homed
* 61184-65519 (0xef00-0xffef): UIDs for dynamic users
On FreeBSD, porters who need a UID for their package can pick a free one from the range 50 to 999 and then register the static allocation.
Some POSIX systems allocate UIDs for new users starting from 500 (
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
,
Red Hat Enterprise Linux
Red Hat Enterprise Linux (RHEL) is a Commercial software, commercial Open-source software, open-source Linux distribution developed by Red Hat for the commerce, commercial market. Red Hat Enterprise Linux is released in server versions for x86-6 ...
till version 6), others start at 1000 (Red Hat Enterprise Linux since version 7,
openSUSE,
Debian
Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of De ...
). On many Linux systems, these ranges are specified in
/etc/login.defs
, for
useradd
and similar tools.
Central UID allocations in enterprise networks (e.g., via
LDAP
The Lightweight Directory Access Protocol (LDAP ) is an open, vendor-neutral, industry standard application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network. Directory serv ...
and
NFS servers) may limit themselves to using only UID numbers well above 1000, and outside the range 60000–65535, to avoid potential conflicts with UIDs locally allocated on client computers. When new users are created locally ,the local system is supposed to check for and avoid conflicts with UID's already existing on NSS'
OS-level virtualization
OS-level virtualization is an operating system (OS) paradigm in which the kernel allows the existence of multiple isolated user space instances, called ''containers'' (LXC, Solaris containers, Docker, Podman), ''zones'' (Solaris containers), '' ...
can remap user identifiers, e.g. using
Linux namespaces
Namespaces are a feature of the Linux kernel that partitions kernel resources such that one set of processes sees one set of resources while another set of processes sees a different set of resources. The feature works by having the same names ...
, and therefore need to allocate ranges into which remapped UIDs and GIDs are mapped:
*
snapd maps UIDs and GIDs into the rang
524288-589823(0x80000-0x8ffff)
*
systemd-nspawn automatic allocates of per-container UID ranges uses the range 524288-1879048191 (0x80000-0x6fffffff)
The systemd authors recommend that
OS-level virtualization
OS-level virtualization is an operating system (OS) paradigm in which the kernel allows the existence of multiple isolated user space instances, called ''containers'' (LXC, Solaris containers, Docker, Podman), ''zones'' (Solaris containers), '' ...
systems should allocate 65536 (2
16) UIDs per container, and map them by adding an integer multiple of 2
16.
Special values
* 0: The
superuser
In computing, the superuser is a special user account used for system administration. Depending on the operating system (OS), the actual name of this account might be root, administrator, admin or supervisor. In some cases, the actual name of th ...
normally has a UID of zero (0).
* −1: The value
(uid_t) -1
is reserved by POSIX to identify an omitted argument.
* 65535: This value is still avoided because it was the API error return value when uid_t was 16 bits.
* Nobody: Historically, the user "
nobody" was assigned UID
-2
by several operating systems, although other values such as 2
15−1 = 32,767 are also in use, such as by
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking N ...
. For compatibility between 16-bit and 32-bit UIDs, many Linux distributions now set it to be 2
16−2 = 65,534; the Linux kernel defaults to returning this value when a 32-bit UID does not fit into the return value of the 16-bit system calls.
Fedora Linux assigns the last UID of the range statically allocated for system use (0–99) to nobody: 99, and calls 65534 instead
nfsnobody
.
Alternatives
NFSv4 was intended to help avoid numeric identifier collisions by identifying users (and groups) in protocol packets using textual “user@domain” names rather than integer numbers. However, as long as operating-system kernels and local file systems continue to use integer user identifiers, this comes at the expense of additional translation steps (using idmap daemon processes), which can introduce additional failure points if local UID mapping mechanisms or databases get configured incorrectly, lost, or out of sync. The “@domain” part of the user name could be used to indicate which authority allocated a particular name, for example in form of
* a
Kerberos realm name
* an
Active Directory
Active Directory (AD) is a directory service developed by Microsoft for Windows domain networks. It is included in most Windows Server operating systems as a set of processes and services. Initially, Active Directory was used only for centr ...
domain name
* the name of an operating-system vendor (for distribution-specific allocations)
* the name of a computer (for device-specific allocations)
But in practice many existing implementations only allow setting the NFSv4 domain to a fixed value, thereby rendering it useless.
See also
*
setuid
The Unix access rights flags setuid and setgid (short for ''set user identity'' and ''set group identity'') allow users to run an executable with the file system permissions of the executable's owner or group respectively and to change behaviour ...
*
Sticky bit
*
Group identifier
*
Process identifier
In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process. This number may be used as a parameter in vario ...
*
File system permissions
Most file systems include attributes of files and directories that control the ability of users to read, change, navigate, and execute the contents of the file system. In some cases, menu options or functions may be made visible or hidden depending ...
*
Open (system call)
For most file systems, a program initializes access to a file in a file system using the open system call. This allocates resources associated to the file (the file descriptor), and returns a handle that the process will use to refer to that fil ...
*
Mount (Unix)
In computing, mount is a command in various operating systems. Before a user can access a file on a Unix-like machine, the file system on the device which contains the file needs to be mounted with the mount command. Frequently mount is used f ...
*
FAT access rights
*
Security Identifier (SID) – the
Windows NT
Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system.
The first version of Wi ...
equivalent
References
{{DEFAULTSORT:User Identifier
Unix
Unix file system technology