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(3), 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       All  of  the  processes in a session share a controlling terminal.  The
57       controlling terminal is established when the session leader first opens
58       a  terminal  (unless  the  O_NOCTTY  flag  is  specified  when  calling
59       open(2)).  A terminal may be the controlling terminal of  at  most  one
60       session.
61
62       At  most  one of the jobs in a session may be the foreground job; other
63       jobs in the session are background jobs.  Only the foreground  job  may
64       read  from  the  terminal; when a process in the background attempts to
65       read from the terminal, its process group is  sent  a  SIGTTIN  signal,
66       which suspends the job.  If the TOSTOP flag has been set for the termi‐
67       nal (see termios(3)), then only the foreground job  may  write  to  the
68       terminal;  writes from background job cause a SIGTTOU signal to be gen‐
69       erated, which suspends the job.  When terminal  keys  that  generate  a
70       signal (such as the interrupt key, normally control-C) are pressed, the
71       signal is sent to the processes in the foreground job.
72
73       Various system calls and library functions may operate on  all  members
74       of  a process group, including kill(2), killpg(3), getpriority(2), set‐
75       priority(2), ioprio_get(2), ioprio_set(2), waitid(2),  and  waitpid(2).
76       See  also  the  discussion  of the F_GETOWN, F_GETOWN_EX, F_SETOWN, and
77       F_SETOWN_EX operations in fcntl(2).
78
79   User and group identifiers
80       Each process has various associated user and group IDs.  These IDs  are
81       integers,  respectively  represented  using  the  types uid_t and gid_t
82       (defined in <sys/types.h>).
83
84       On Linux, each process has the following user and group identifiers:
85
86       *  Real user ID and real group ID.  These IDs determine  who  owns  the
87          process.   A  process  can  obtain  its  real  user (group) ID using
88          getuid(2) (getgid(2)).
89
90       *  Effective user ID and effective group ID.  These IDs are used by the
91          kernel  to determine the permissions that the process will have when
92          accessing shared resources such as message  queues,  shared  memory,
93          and  semaphores.  On most UNIX systems, these IDs also determine the
94          permissions when accessing files.  However, Linux uses the  filesys‐
95          tem  IDs  described  below  for this task.  A process can obtain its
96          effective user (group) ID using geteuid(2) (getegid(2)).
97
98       *  Saved set-user-ID and saved set-group-ID.  These  IDs  are  used  in
99          set-user-ID  and  set-group-ID programs to save a copy of the corre‐
100          sponding effective IDs that were set when the program  was  executed
101          (see  execve(2)).   A set-user-ID program can assume and drop privi‐
102          leges by switching its effective user ID back and forth between  the
103          values in its real user ID and saved set-user-ID.  This switching is
104          done via calls to seteuid(2), setreuid(2), or setresuid(2).  A  set-
105          group-ID  program  performs  the  analogous  tasks using setegid(2),
106          setregid(2), or setresgid(2).  A process can obtain its  saved  set-
107          user-ID (set-group-ID) using getresuid(2) (getresgid(2)).
108
109       *  Filesystem  user ID and filesystem group ID (Linux-specific).  These
110          IDs, in conjunction  with  the  supplementary  group  IDs  described
111          below,  are  used  to determine permissions for accessing files; see
112          path_resolution(7) for details.  Whenever a process's effective user
113          (group)  ID  is  changed,  the kernel also automatically changes the
114          filesystem user (group) ID to the  same  value.   Consequently,  the
115          filesystem  IDs  normally  have the same values as the corresponding
116          effective ID, and the semantics for file-permission checks are  thus
117          the  same on Linux as on other UNIX systems.  The filesystem IDs can
118          be made to differ from the effective IDs by calling setfsuid(2)  and
119          setfsgid(2).
120
121       *  Supplementary group IDs.  This is a set of additional group IDs that
122          are used for permission checks when accessing files and other shared
123          resources.  On Linux kernels before 2.6.4, a process can be a member
124          of up to 32 supplementary groups; since kernel 2.6.4, a process  can
125          be  a  member  of  up  to  65536  supplementary  groups.   The  call
126          sysconf(_SC_NGROUPS_MAX) can be used to determine the number of sup‐
127          plementary groups of which a process may be a member.  A process can
128          obtain its set of supplementary group IDs  using  getgroups(2),  and
129          can modify the set using setgroups(2).
130
131       A child process created by fork(2) inherits copies of its parent's user
132       and groups IDs.  During an execve(2), a process's real user  and  group
133       ID  and  supplementary group IDs are preserved; the effective and saved
134       set IDs may be changed, as described in execve(2).
135
136       Aside from the purposes noted above, a  process's  user  IDs  are  also
137       employed in a number of other contexts:
138
139       *  when determining the permissions for sending signals (see kill(2));
140
141       *  when  determining  the  permissions  for  setting process-scheduling
142          parameters (nice value, real time scheduling  policy  and  priority,
143          CPU  affinity,  I/O  priority) using setpriority(2), sched_setaffin‐
144          ity(2), sched_setscheduler(2), sched_setparam(2),  sched_setattr(2),
145          and ioprio_set(2);
146
147       *  when checking resource limits (see getrlimit(2));
148
149       *  when  checking the limit on the number of inotify instances that the
150          process may create (see inotify(7)).
151

CONFORMING TO

153       Process IDs, parent process IDs, process group IDs, and session IDs are
154       specified  in  POSIX.1.   The  real,  effective, and saved set user and
155       groups IDs, and the supplementary group IDs, are specified in  POSIX.1.
156       The filesystem user and group IDs are a Linux extension.
157

NOTES

159       Various  fields in the /proc/[pid]/status file show the process creden‐
160       tials described above.  See proc(5) for further information.
161
162       The POSIX threads specification requires that credentials are shared by
163       all  of  the threads in a process.  However, at the kernel level, Linux
164       maintains separate user and group credentials  for  each  thread.   The
165       NPTL  threading implementation does some work to ensure that any change
166       to user or group credentials (e.g., calls to  setuid(2),  setresuid(2))
167       is  carried  through  to  all  of  the POSIX threads in a process.  See
168       nptl(7) for further details.
169

SEE ALSO

171       bash(1), csh(1), groups(1), id(1), newgrp(1), ps(1),  runuser(1),  set‐
172       priv(1),  sg(1),  su(1),  access(2),  execve(2), faccessat(2), fork(2),
173       getgroups(2), getpgrp(2), getpid(2),  getppid(2),  getsid(2),  kill(2),
174       setegid(2),   seteuid(2),  setfsgid(2),  setfsuid(2),  setgid(2),  set‐
175       groups(2),   setpgid(2),   setresgid(2),    setresuid(2),    setsid(2),
176       setuid(2), waitpid(2), euidaccess(3), initgroups(3), killpg(3), tcgetp‐
177       grp(3),  tcgetsid(3),  tcsetpgrp(3),  group(5),  passwd(5),  shadow(5),
178       capabilities(7),  namespaces(7), path_resolution(7), pid_namespaces(7),
179       pthreads(7), signal(7), unix(7), user_namespaces(7), sudo(8)
180

COLOPHON

182       This page is part of release 5.04 of the Linux  man-pages  project.   A
183       description  of  the project, information about reporting bugs, and the
184       latest    version    of    this    page,    can     be     found     at
185       https://www.kernel.org/doc/man-pages/.
186
187
188
189Linux                             2019-08-02                    CREDENTIALS(7)
Impressum