1 .\" Copyright (c) 2007 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" 2007-06-13 Creation
7 .TH credentials 7 (date) "Linux man-pages (unreleased)"
9 credentials \- process identifiers
12 Each process has a unique nonnegative integer identifier
13 that is assigned when the process is created using
15 A process can obtain its PID using
17 A PID is represented using the type
22 PIDs are used in a range of system calls to identify the process
23 affected by the call, for example:
27 .\" .BR sched_rr_get_interval (2),
28 .\" .BR sched_getaffinity (2),
29 .\" .BR sched_setaffinity (2),
30 .\" .BR sched_getparam (2),
31 .\" .BR sched_setparam (2),
32 .\" .BR sched_setscheduler (2),
33 .\" .BR sched_getscheduler (2),
43 A process's PID is preserved across an
45 .SS Parent process ID (PPID)
46 A process's parent process ID identifies the process that created
49 A process can obtain its PPID using
51 A PPID is represented using the type
54 A process's PPID is preserved across an
56 .SS Process group ID and session ID
57 Each process has a session ID and a process group ID,
58 both represented using the type
60 A process can obtain its session ID using
62 and its process group ID using
67 inherits its parent's session ID and process group ID.
68 A process's session ID and process group ID are preserved across an
71 Sessions and process groups are abstractions devised to support shell
73 A process group (sometimes called a "job") is a collection of
74 processes that share the same process group ID;
75 the shell creates a new process group for the process(es) used
76 to execute single command or pipeline (e.g., the two processes
77 created to execute the command "ls\ |\ wc" are placed in the
79 A process's group membership can be set using
81 The process whose process ID is the same as its process group ID is the
82 \fIprocess group leader\fP for that group.
84 A session is a collection of processes that share the same session ID.
85 All of the members of a process group also have the same session ID
86 (i.e., all of the members of a process group always belong to the
87 same session, so that sessions and process groups form a strict
88 two-level hierarchy of processes.)
89 A new session is created when a process calls
91 which creates a new session whose session ID is the same
92 as the PID of the process that called
94 The creator of the session is called the \fIsession leader\fP.
96 All of the processes in a session share a
97 .IR "controlling terminal" .
98 The controlling terminal is established when the session leader
99 first opens a terminal (unless the
101 flag is specified when calling
103 A terminal may be the controlling terminal of at most one session.
105 At most one of the jobs in a session may be the
106 .IR "foreground job" ;
107 other jobs in the session are
108 .IR "background jobs" .
109 Only the foreground job may read from the terminal;
110 when a process in the background attempts to read from the terminal,
111 its process group is sent a
113 signal, which suspends the job.
116 flag has been set for the terminal (see
118 then only the foreground job may write to the terminal;
119 writes from background jobs cause a
121 signal to be generated, which suspends the job.
122 When terminal keys that generate a signal (such as the
124 key, normally control-C)
125 are pressed, the signal is sent to the processes in the foreground job.
127 Various system calls and library functions
128 may operate on all members of a process group,
139 See also the discussion of the
147 .SS User and group identifiers
148 Each process has various associated user and group IDs.
149 These IDs are integers, respectively represented using the types
156 On Linux, each process has the following user and group identifiers:
158 Real user ID and real group ID.
159 These IDs determine who owns the process.
160 A process can obtain its real user (group) ID using
164 Effective user ID and effective group ID.
165 These IDs are used by the kernel to determine the permissions
166 that the process will have when accessing shared resources such
167 as message queues, shared memory, and semaphores.
168 On most UNIX systems, these IDs also determine the
169 permissions when accessing files.
170 However, Linux uses the filesystem IDs described below
172 A process can obtain its effective user (group) ID using
176 Saved set-user-ID and saved set-group-ID.
177 These IDs are used in set-user-ID and set-group-ID programs to save
178 a copy of the corresponding effective IDs that were set when
179 the program was executed (see
181 A set-user-ID program can assume and drop privileges by
182 switching its effective user ID back and forth between the values
183 in its real user ID and saved set-user-ID.
184 This switching is done via calls to
189 A set-group-ID program performs the analogous tasks using
194 A process can obtain its saved set-user-ID (set-group-ID) using
196 .RB ( getresgid (2)).
198 Filesystem user ID and filesystem group ID (Linux-specific).
199 These IDs, in conjunction with the supplementary group IDs described
200 below, are used to determine permissions for accessing files; see
201 .BR path_resolution (7)
203 Whenever a process's effective user (group) ID is changed,
204 the kernel also automatically changes the filesystem user (group) ID
206 Consequently, the filesystem IDs normally have the same values
207 as the corresponding effective ID, and the semantics for file-permission
208 checks are thus the same on Linux as on other UNIX systems.
209 The filesystem IDs can be made to differ from the effective IDs
215 Supplementary group IDs.
216 This is a set of additional group IDs that are used for permission
217 checks when accessing files and other shared resources.
219 a process can be a member of up to 32 supplementary groups;
221 a process can be a member of up to 65536 supplementary groups.
223 .I sysconf(_SC_NGROUPS_MAX)
224 can be used to determine the number of supplementary groups
225 of which a process may be a member.
226 .\" Since Linux 2.6.4, the limit is visible via the read-only file
227 .\" /proc/sys/kernel/ngroups_max.
228 .\" As at 2.6.22-rc2, this file is still read-only.
229 A process can obtain its set of supplementary group IDs using
232 A child process created by
234 inherits copies of its parent's user and groups IDs.
237 a process's real user and group ID and supplementary
238 group IDs are preserved;
239 the effective and saved set IDs may be changed, as described in
242 Aside from the purposes noted above,
243 a process's user IDs are also employed in a number of other contexts:
245 when determining the permissions for sending signals (see
248 when determining the permissions for setting
249 process-scheduling parameters (nice value, real time
250 scheduling policy and priority, CPU affinity, I/O priority) using
252 .BR sched_setaffinity (2),
253 .BR sched_setscheduler (2),
254 .BR sched_setparam (2),
255 .BR sched_setattr (2),
259 when checking resource limits (see
262 when checking the limit on the number of inotify instances
263 that the process may create (see
266 .SS Modifying process user and group IDs
267 Subject to rules described in the relevant manual pages,
268 a process can use the following APIs to modify its user and group IDs:
272 Modify the process's real (and possibly effective and saved-set)
277 Modify the process's effective user (group) ID.
279 .BR setfsuid (2)\~(\c
281 Modify the process's filesystem user (group) ID.
283 .BR setreuid (2)\~(\c
285 Modify the process's real and effective (and possibly saved-set)
288 .BR setresuid (2)\~(\c
290 Modify the process's real, effective, and saved-set user (group) IDs.
293 Modify the process's supplementary group list.
295 Any changes to a process's effective user (group) ID
296 are automatically carried over to the process's
297 filesystem user (group) ID.
298 Changes to a process's effective user or group ID can also affect the
299 process "dumpable" attribute, as described in
302 Changes to process user and group IDs can affect the capabilities
303 of the process, as described in
304 .BR capabilities (7).
306 Process IDs, parent process IDs, process group IDs, and session IDs
307 are specified in POSIX.1.
308 The real, effective, and saved set user and groups IDs,
309 and the supplementary group IDs, are specified in POSIX.1.
311 The filesystem user and group IDs are a Linux extension.
313 Various fields in the
314 .IR /proc/ pid /status
315 file show the process credentials described above.
318 for further information.
320 The POSIX threads specification requires that
321 credentials are shared by all of the threads in a process.
322 However, at the kernel level, Linux maintains separate user and group
323 credentials for each thread.
324 The NPTL threading implementation does some work to ensure
325 that any change to user or group credentials
329 is carried through to all of the POSIX threads in a process.
375 .BR capabilities (7),
377 .BR path_resolution (7),
378 .BR pid_namespaces (7),
381 .BR system_data_types (7),
383 .BR user_namespaces (7),