1CREDENTIALS(7)             Linux Programmer's Manual            CREDENTIALS(7)
2
3
4

NAME

6       credentials - process identifiers
7

DESCRIPTION

9   Process ID (PID)
10       Each  process  has  a  unique  nonnegative  integer  identifier that is
11       assigned when the process is created  using  fork(2).   A  process  can
12       obtain  its  PID  using getpid(2).  A PID is represented using the type
13       pid_t (defined in <sys/types.h>).
14
15       PIDs are used in a range  of  system  calls  to  identify  the  process
16       affected  by  the call, for example: kill(2), ptrace(2), setpriority(2)
17       setpgid(2), setsid(2), sigqueue(2), and waitpid(2).
18
19       A process's PID is preserved across an execve(2).
20
21   Parent Process ID (PPID)
22       A process's parent process ID identifies the process that created  this
23       process using fork(2).  A process can obtain its PPID using getppid(2).
24       A PPID is represented using the type pid_t.
25
26       A process's PPID is preserved across an execve(2).
27
28   Process Group ID and Session ID
29       Each process has a session ID and a process group ID, both  represented
30       using  the  type pid_t.  A process can obtain its session ID using get‐
31       sid(2), and its process group ID using getpgrp(2).
32
33       A child created by fork(2) inherits its parent's session ID and process
34       group  ID.   A  process's session ID and process group ID are preserved
35       across an execve(2).
36
37       Sessions and process groups are abstractions devised to  support  shell
38       job  control.   A process group (sometimes called a "job") is a collec‐
39       tion of processes that share the same process group ID; the shell  cre‐
40       ates  a  new  process  group for the process(es) used to execute single
41       command or pipeline (e.g., the two processes  created  to  execute  the
42       command  "ls | wc"  are placed in the same process group).  A process's
43       group membership can  be  set  using  setpgid(2).   The  process  whose
44       process  ID  is  the  same as its process group ID is the process group
45       leader for that group.
46
47       A session is a collection of processes that share the same session  ID.
48       All  of  the  members  of a process group also have the same session ID
49       (i.e., all of the members of a process group always belong to the  same
50       session,  so  that  sessions and process groups form a strict two-level
51       hierarchy of processes.)  A new session is created when a process calls
52       setsid(2),  which creates a new session whose session ID is the same as
53       the PID of the process that called setsid(2).  The creator of the  ses‐
54       sion is called the session leader.
55
56   User and Group Identifiers
57       Each process has various associated user and groups IDs.  These IDs are
58       integers, respectively represented using  the  types  uid_t  and  gid_t
59       (defined in <sys/types.h>).
60
61       On Linux, each process has the following user and group identifiers:
62
63       *  Real  user  ID  and real group ID.  These IDs determine who owns the
64          process.  A process can  obtain  its  real  user  (group)  ID  using
65          getuid(2) (getgid(2)).
66
67       *  Effective user ID and effective group ID.  These IDs are used by the
68          kernel to determine the permissions that the process will have  when
69          accessing  shared  resources  such as message queues, shared memory,
70          and semaphores.  On most Unix systems, these IDs also determine  the
71          permissions when accessing files.  However, Linux uses the file sys‐
72          tem IDs described below for this task.  A  process  can  obtain  its
73          effective user (group) ID using geteuid(2) (getegid(2)).
74
75       *  Saved  set-user-ID  and  saved  set-group-ID.  These IDs are used in
76          set-user-ID and set-group-ID programs to save a copy of  the  corre‐
77          sponding  effective  IDs that were set when the program was executed
78          (see execve(2)).  A set-user-ID program can assume and  drop  privi‐
79          leges  by switching its effective user ID back and forth between the
80          values in its real user ID and saved set-user-ID.  This switching is
81          done  via calls to seteuid(2), setreuid(2), or setresuid(2).  A set-
82          group-ID program performs  the  analogous  tasks  using  setegid(2),
83          setregid(2),  or  setresgid(2).  A process can obtain its saved set-
84          user-ID (set-group-ID) using getresuid(2) (getresgid(2)).
85
86       *  File system user ID  and  file  system  group  ID  (Linux-specific).
87          These IDs, in conjunction with the supplementary group IDs described
88          below, are used to determine permissions for  accessing  files;  see
89          path_resolution(7) for details.  Whenever a process's effective user
90          (group) ID is changed, the kernel  also  automatically  changes  the
91          file  system  user  (group) ID to the same value.  Consequently, the
92          file system IDs normally have the same values as  the  corresponding
93          effective  ID, and the semantics for file-permission checks are thus
94          the same on Linux as on other Unix systems.  The file system IDs can
95          be  made to differ from the effective IDs by calling setfsuid(2) and
96          setfsgid(2).
97
98       *  Supplementary group IDs.  This is a set of additional group IDs that
99          are used for permission checks when accessing files and other shared
100          resources.  On Linux kernels before 2.6.4, a process can be a member
101          of  up to 32 supplementary groups; since kernel 2.6.4, a process can
102          be  a  member  of  up  to  65536  supplementary  groups.   The  call
103          sysconf(_SC_NGROUPS_MAX) can be used to determine the number of sup‐
104          plementary groups of which a process may be a member.  A process can
105          obtain  its  set  of supplementary group IDs using getgroups(2), and
106          can modify the set using setgroups(2).
107
108       A child process created by fork(2) inherits copies of its parent's user
109       and  groups  IDs.  During an execve(2), a process's real user and group
110       ID and supplementary group IDs are preserved; the effective  and  saved
111       set IDs may be changed, as described in execve(2).
112
113       Aside  from  the  purposes  noted  above, a process's user IDs are also
114       employed in a number of other contexts:
115
116       *  when determining the permissions for sending signals — see kill(2);
117
118       *  when determining  the  permissions  for  setting  process-scheduling
119          parameters  (nice  value,  real time scheduling policy and priority,
120          CPU affinity, I/O priority)  using  setpriority(2),  sched_setaffin‐
121          ity(2), sched_setscheduler(2), sched_setparam(2), and ioprio_set(2);
122
123       *  when checking resource limits; see getrlimit(2);
124
125       *  when  checking the limit on the number of inotify instances that the
126          process may create; see inotify(7).
127

CONFORMING TO

129       Process IDs, parent process IDs, process group IDs, and session IDs are
130       specified in POSIX.1-2001.  The real, effective, and saved set user and
131       groups  IDs,  and  the  supplementary  group  IDs,  are  specified   in
132       POSIX.1-2001.   The  file  system user and group IDs are a Linux exten‐
133       sion.
134

NOTES

136       The POSIX threads specification requires that credentials are shared by
137       all  of  the threads in a process.  However, at the kernel level, Linux
138       maintains separate user and group credentials  for  each  thread.   The
139       NPTL  threading implementation does some work to ensure that any change
140       to user or group credentials (e.g., calls to  setuid(2),  setresuid(2),
141       etc.)  is carried through to all of the POSIX threads in a process.
142

SEE ALSO

144       bash(1),  csh(1),  ps(1),  access(2), execve(2), faccessat(2), fork(2),
145       getpgrp(2), getpid(2), getppid(2), getsid(2), kill(2), killpg(2), sete‐
146       gid(2),  seteuid(2), setfsgid(2), setfsuid(2), setgid(2), setgroups(2),
147       setresgid(2), setresuid(2), setuid(2), waitpid(2), euidaccess(3), init‐
148       groups(3),  tcgetpgrp(3),  tcsetpgrp(3),  capabilities(7), path_resolu‐
149       tion(7), unix(7)
150

COLOPHON

152       This page is part of release 3.25 of the Linux  man-pages  project.   A
153       description  of  the project, and information about reporting bugs, can
154       be found at http://www.kernel.org/doc/man-pages/.
155
156
157
158Linux                             2008-06-03                    CREDENTIALS(7)
Impressum