This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Group identifier" โ news ยท newspapers ยท books ยท scholar ยท JSTOR (September 2014) (Learn how and when to remove this message) |
In Unix-like systems, multiple users can be put into groups. POSIX and conventional Unix file system permissions are organized into three classes, user, group, and others. The use of groups allows additional abilities to be delegated in an organized fashion, such as access to disks, printers, and other peripherals. This method, among others, also enables the superuser to delegate some administrative tasks to normal users, similar to the Administrators group on Microsoft Windows NT and its derivatives.
A group identifier, often abbreviated to GID, is a numeric value used to represent a specific group.[1] The range of values for a GID varies amongst different systems; at the very least, a GID can be between 0 and 32,767, with one restriction: the login group for the superuser must have GID 0. This numeric value is used to refer to groups in the /etc/passwd and /etc/group files or their equivalents. Shadow password files and Network Information Service also refer to numeric GIDs. The group identifier is a necessary component of Unix file systems and processes.
Process attributes
[edit]The POSIX standard supports three different GID fields in the process descriptor table, to allow privileged processes to take on different roles dynamically:
Effective group ID
[edit]The effective GID (egid) of a process is used for file access checks 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 UNIX System V 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.[2]
Real group ID
[edit]The real GID (rgid) identify the real group owner of the process.
Saved group ID
[edit]The saved group ID is used when a program running with elevated privileges needs to do some unprivileged work temporarily; changing egid from a privileged value (typically 0) to some unprivileged value (anything other than the privileged value) causes the privileged value to be stored in sgid. Later, a program's egid can be set back to the value stored in sgid, so that elevated privileges can be restored; an unprivileged process may set its egid to one of only three values: the value of rgid, the value of sgid, or the value of egid.
Supplementary groups
[edit]Every user must be a member of at least one group, the primary group, which is identified by the numeric GID of the user's entry in the passwd database, which can be viewed with the command getent passwd (usually stored in /etc/passwd or LDAP). This group is referred to as the primary group ID. A user may be listed as member of additional groups in the relevant entries in the group database, which can be viewed with getent group (usually stored in /etc/group or LDAP); the IDs of these groups are referred to as supplementary group IDs.
Conventions
[edit]Type
[edit]Originally, a signed 16-bit integer was used. Since the sign was not necessary โ negative numbers do not make valid group IDs โ an unsigned integer is now used instead, allowing group IDs between 0 and 65,535. Modern operating systems usually use unsigned 32-bit integers, which allow for group IDs between 0 and 4,294,967,295.
Reserved ranges
[edit]Many Linux systems reserve the GID number range 0 to 99 for statically allocated groups, and either 100โ499 or 100โ999 for groups dynamically allocated by the system in post-installation scripts. These ranges are often specified in /etc/login.defs, for useradd, groupadd and similar tools.
On FreeBSD, porters who need a GID for their package can pick a free one from the range 50 to 999 and then register this static allocation in ports/GIDs.[3]
Special values
[edit]- 0: The superuser normally has a GID of zero (0).
- โ1: The value
(gid_t) -1is reserved by POSIX to identify an omitted argument.[4] - 65,534: The Linux kernel defaults to 216โ2 = 65,534 (which many Linux distributions map to the group name "nogroup") when a 32-bit GID does not fit into the return value of a 16-bit system call.[5] The value is also returned by idmapd if a group name in an incoming NFSv4 packet does not match any known group on the system.
Personal groups
[edit]Many system administrators allocate for each user also a personal primary group that has the same name as the user's login name, and often also has the same numeric GID as the user's UID. Such personal groups have no other members and make collaboration with other users in shared directories easier, by allowing users to habitually work with umask 0002. This way, newly created files can have by default write permissions enabled for group members, because this will normally only enable write access for members of the personal group, that is only for the file's owner. However, if a file is created in a shared directory that belongs to another group and has the setgid bit set, then the created file will automatically become writable to members of that directory's group as well.
On many Linux systems, the USERGROUPS_ENAB variable in /etc/login.defs controls whether commands like useradd or userdel automatically add or delete an associated personal group.
See also
[edit]References
[edit]- ^ "Definitions". pubs.opengroup.org. Retrieved 2021-12-06.
- ^
chmod(1)โ Solaris 11.4 User Commands Reference Manual - ^ FreeBSD Porter's Handbook, Section 6.26: Adding Users and Groups
- ^ "chown". pubs.opengroup.org. Retrieved 2021-12-06.
- ^ "Namespaces in operation, part 5: User namespaces [LWN.net]". lwn.net. Retrieved 2021-12-06.
