# CREDENTIALS - process identifiers - man(7) - [phpMan]

[_credentials_(7)](https://www.chedong.com/phpMan.php/man/credentials/7/markdown)                    Miscellaneous Information Manual                    [_credentials_(7)](https://www.chedong.com/phpMan.php/man/credentials/7/markdown)

## NAME
       credentials - process identifiers

## DESCRIPTION
### Process ID (PID)
       Each process has a unique nonnegative integer identifier that is assigned when the process is
       created  using  [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown).  A process can obtain its PID using [**getpid**(2)](https://www.chedong.com/phpMan.php/man/getpid/2/markdown).  A PID is represented
       using the type _pid_t_ (defined in _<sys/types.h>_).

       PIDs are used in a range of system calls to identify the process affected by  the  call,  for
       example:  [**kill**(2)](https://www.chedong.com/phpMan.php/man/kill/2/markdown),  [**ptrace**(2)](https://www.chedong.com/phpMan.php/man/ptrace/2/markdown),  [**setpriority**(2)](https://www.chedong.com/phpMan.php/man/setpriority/2/markdown), [**setpgid**(2)](https://www.chedong.com/phpMan.php/man/setpgid/2/markdown), [**setsid**(2)](https://www.chedong.com/phpMan.php/man/setsid/2/markdown), [**sigqueue**(3)](https://www.chedong.com/phpMan.php/man/sigqueue/3/markdown), and **wait‐**
       [**pid**(2)](https://www.chedong.com/phpMan.php/man/pid/2/markdown).

       A process's PID is preserved across an [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown).

### Parent process ID (PPID)
       A process's parent process ID identifies the process that created this process using [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown).
       A process can obtain its PPID using [**getppid**(2)](https://www.chedong.com/phpMan.php/man/getppid/2/markdown).  A PPID is represented using the type _pid_t_.

       A process's PPID is preserved across an [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown).

### Process group ID and session ID
       Each process has a session ID and a process group ID, both represented using the type  _pid_t_.
       A  process  can  obtain  its session ID using [**getsid**(2)](https://www.chedong.com/phpMan.php/man/getsid/2/markdown), and its process group ID using **getp‐**
       [**grp**(2)](https://www.chedong.com/phpMan.php/man/grp/2/markdown).

       A child created by [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown) inherits  its  parent's  session  ID  and  process  group  ID.   A
       process's session ID and process group ID are preserved across an [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown).

       Sessions and process groups are abstractions devised to support shell job control.  A process
       group  (sometimes  called  a  "job") is a collection of processes that share the same process
       group ID; the shell creates a new process group for the process(es) used  to  execute  single
       command  or  pipeline  (e.g.,  the two processes created to execute the command "ls | wc" are
       placed in the same process group).  A process's group membership can be set using [**setpgid**(2)](https://www.chedong.com/phpMan.php/man/setpgid/2/markdown).
       The process whose process ID is the same as its process group ID is the _process_ _group_  _leader_
       for that group.

       A session is a collection of processes that share the same session ID.  All of the members of
       a  process  group  also have the same session ID (i.e., all of the members of a process group
       always belong to the same session, so that sessions and process groups  form  a  strict  two-
       level  hierarchy  of  processes.)   A  new session is created when a process calls [**setsid**(2)](https://www.chedong.com/phpMan.php/man/setsid/2/markdown),
       which creates a new session whose session ID is the same as  the  PID  of  the  process  that
       called [**setsid**(2)](https://www.chedong.com/phpMan.php/man/setsid/2/markdown).  The creator of the session is called the _session_ _leader_.

       All  of the processes in a session share a _controlling_ _terminal_.  The controlling terminal is
       established when the session leader first opens a terminal (unless the **O_NOCTTY **flag is spec‐
       ified when calling [**open**(2)](https://www.chedong.com/phpMan.php/man/open/2/markdown)).  A terminal may be the controlling terminal of at most one  ses‐
       sion.

       At most one of the jobs in a session may be the _foreground_ _job_; other jobs in the session are
       _background_  _jobs_.   Only the foreground job may read from the terminal; when a process in the
       background attempts to read from the terminal, its process group is sent  a  **SIGTTIN  **signal,
       which  suspends  the job.  If the **TOSTOP **flag has been set for the terminal (see [**termios**(3)](https://www.chedong.com/phpMan.php/man/termios/3/markdown)),
       then only the foreground job may write to the terminal; writes from background jobs  cause  a
       **SIGTTOU  **signal  to be generated, which suspends the job.  When terminal keys that generate a
       signal (such as the _interrupt_ key, normally control-C) are pressed, the signal is sent to the
       processes in the foreground job.

       Various system calls and library functions may operate on all members of a process group, in‐
       cluding [**kill**(2)](https://www.chedong.com/phpMan.php/man/kill/2/markdown), [**killpg**(3)](https://www.chedong.com/phpMan.php/man/killpg/3/markdown),  [**getpriority**(2)](https://www.chedong.com/phpMan.php/man/getpriority/2/markdown),  [**setpriority**(2)](https://www.chedong.com/phpMan.php/man/setpriority/2/markdown),  [**ioprio_get**(2)](https://www.chedong.com/phpMan.php/man/ioprioget/2/markdown),  [**ioprio_set**(2)](https://www.chedong.com/phpMan.php/man/ioprioset/2/markdown),
       [**waitid**(2)](https://www.chedong.com/phpMan.php/man/waitid/2/markdown),  and  [**waitpid**(2)](https://www.chedong.com/phpMan.php/man/waitpid/2/markdown).  See also the discussion of the **F_GETOWN**, **F_GETOWN_EX**, **F_SETOWN**,
       and **F_SETOWN_EX **operations in [**fcntl**(2)](https://www.chedong.com/phpMan.php/man/fcntl/2/markdown).

### User and group identifiers
       Each process has various associated user and group IDs.  These IDs are integers, respectively
       represented using the types _uid_t_ and _gid_t_ (defined in _<sys/types.h>_).

       On Linux, each process has the following user and group identifiers:

       •  Real user ID and real group ID.  These IDs determine who owns the process.  A process  can
          obtain its real user (group) ID using [**getuid**(2)](https://www.chedong.com/phpMan.php/man/getuid/2/markdown) ([**getgid**(2)](https://www.chedong.com/phpMan.php/man/getgid/2/markdown)).

       •  Effective  user  ID and effective group ID.  These IDs are used by the kernel to determine
          the permissions that the process will have when accessing shared resources such as message
          queues, shared memory, and semaphores.  On most UNIX systems, these IDs also determine the
          permissions when accessing files.  However, Linux uses the filesystem IDs described  below
          for this task.  A process can obtain its effective user (group) ID using [**geteuid**(2)](https://www.chedong.com/phpMan.php/man/geteuid/2/markdown) (**gete‐**
          [**gid**(2)](https://www.chedong.com/phpMan.php/man/gid/2/markdown)).

       •  Saved  set-user-ID  and  saved  set-group-ID.   These IDs are used in set-user-ID and set-
          group-ID programs to save a copy of the corresponding effective IDs that were set when the
          program was executed (see [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown)).  A set-user-ID program can assume  and  drop  privi‐
          leges  by  switching  its  effective user ID back and forth between the values in its real
          user ID and saved set-user-ID.  This switching  is  done  via  calls  to  [**seteuid**(2)](https://www.chedong.com/phpMan.php/man/seteuid/2/markdown),  **se‐**
          [**treuid**(2)](https://www.chedong.com/phpMan.php/man/treuid/2/markdown),  or  [**setresuid**(2)](https://www.chedong.com/phpMan.php/man/setresuid/2/markdown).   A  set-group-ID program performs the analogous tasks using
          [**setegid**(2)](https://www.chedong.com/phpMan.php/man/setegid/2/markdown), [**setregid**(2)](https://www.chedong.com/phpMan.php/man/setregid/2/markdown), or [**setresgid**(2)](https://www.chedong.com/phpMan.php/man/setresgid/2/markdown).  A process  can  obtain  its  saved  set-user-ID
          (set-group-ID) using [**getresuid**(2)](https://www.chedong.com/phpMan.php/man/getresuid/2/markdown) ([**getresgid**(2)](https://www.chedong.com/phpMan.php/man/getresgid/2/markdown)).

       •  Filesystem  user  ID  and filesystem group ID (Linux-specific).  These IDs, in conjunction
          with the supplementary group IDs described below, are used to  determine  permissions  for
          accessing  files; see [**path_resolution**(7)](https://www.chedong.com/phpMan.php/man/pathresolution/7/markdown) for details.  Whenever a process's effective user
          (group) ID is changed, the kernel also automatically changes the filesystem  user  (group)
          ID  to  the same value.  Consequently, the filesystem IDs normally have the same values as
          the corresponding effective ID, and the semantics for file-permission checks are thus  the
          same on Linux as on other UNIX systems.  The filesystem IDs can be made to differ from the
          effective IDs by calling [**setfsuid**(2)](https://www.chedong.com/phpMan.php/man/setfsuid/2/markdown) and [**setfsgid**(2)](https://www.chedong.com/phpMan.php/man/setfsgid/2/markdown).

       •  Supplementary  group IDs.  This is a set of additional group IDs that are used for permis‐
          sion checks when accessing files and  other  shared  resources.   Before  Linux  2.6.4,  a
          process can be a member of up to 32 supplementary groups; since Linux 2.6.4, a process can
          be a member of up to 65536 supplementary groups.  The call _sysconf(_SC_NGROUPS_MAX)_ can be
          used  to  determine the number of supplementary groups of which a process may be a member.
          A process can obtain its set of supplementary group IDs using [**getgroups**(2)](https://www.chedong.com/phpMan.php/man/getgroups/2/markdown).

       A child process created by [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown) inherits copies of its parent's user and groups IDs.  Dur‐
       ing an [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown), a process's real user and group ID and supplementary  group  IDs  are  pre‐
       served; the effective and saved set IDs may be changed, as described in [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown).

       Aside  from  the  purposes noted above, a process's user IDs are also employed in a number of
       other contexts:

       •  when determining the permissions for sending signals (see [**kill**(2)](https://www.chedong.com/phpMan.php/man/kill/2/markdown));

       •  when determining the permissions for setting process-scheduling  parameters  (nice  value,
          real  time  scheduling  policy  and  priority, CPU affinity, I/O priority) using **setprior‐**
          [**ity**(2)](https://www.chedong.com/phpMan.php/man/ity/2/markdown), [**sched_setaffinity**(2)](https://www.chedong.com/phpMan.php/man/schedsetaffinity/2/markdown), [**sched_setscheduler**(2)](https://www.chedong.com/phpMan.php/man/schedsetscheduler/2/markdown), [**sched_setparam**(2)](https://www.chedong.com/phpMan.php/man/schedsetparam/2/markdown),  [**sched_setattr**(2)](https://www.chedong.com/phpMan.php/man/schedsetattr/2/markdown),
          and [**ioprio_set**(2)](https://www.chedong.com/phpMan.php/man/ioprioset/2/markdown);

       •  when checking resource limits (see [**getrlimit**(2)](https://www.chedong.com/phpMan.php/man/getrlimit/2/markdown));

       •  when  checking  the  limit  on the number of inotify instances that the process may create
          (see [**inotify**(7)](https://www.chedong.com/phpMan.php/man/inotify/7/markdown)).

### Modifying process user and group IDs
       Subject to rules described in the relevant manual pages, a process can use the following APIs
       to modify its user and group IDs:

       [**setuid**(2)](https://www.chedong.com/phpMan.php/man/setuid/2/markdown) ([**setgid**(2)](https://www.chedong.com/phpMan.php/man/setgid/2/markdown))
              Modify the process's real (and possibly effective and saved-set) user (group) IDs.

       [**seteuid**(2)](https://www.chedong.com/phpMan.php/man/seteuid/2/markdown) ([**setegid**(2)](https://www.chedong.com/phpMan.php/man/setegid/2/markdown))
              Modify the process's effective user (group) ID.

       [**setfsuid**(2)](https://www.chedong.com/phpMan.php/man/setfsuid/2/markdown) ([**setfsgid**(2)](https://www.chedong.com/phpMan.php/man/setfsgid/2/markdown))
              Modify the process's filesystem user (group) ID.

       [**setreuid**(2)](https://www.chedong.com/phpMan.php/man/setreuid/2/markdown) ([**setregid**(2)](https://www.chedong.com/phpMan.php/man/setregid/2/markdown))
              Modify the process's real and effective (and possibly saved-set) user (group) IDs.

       [**setresuid**(2)](https://www.chedong.com/phpMan.php/man/setresuid/2/markdown) ([**setresgid**(2)](https://www.chedong.com/phpMan.php/man/setresgid/2/markdown))
              Modify the process's real, effective, and saved-set user (group) IDs.

       [**setgroups**(2)](https://www.chedong.com/phpMan.php/man/setgroups/2/markdown)
              Modify the process's supplementary group list.

       Any changes to a process's effective user (group) ID are automatically carried  over  to  the
       process's  filesystem user (group) ID.  Changes to a process's effective user or group ID can
       also affect the process "dumpable" attribute, as described in [**prctl**(2)](https://www.chedong.com/phpMan.php/man/prctl/2/markdown).

       Changes to process user and group IDs can affect the capabilities  of  the  process,  as  de‐
       scribed in [**capabilities**(7)](https://www.chedong.com/phpMan.php/man/capabilities/7/markdown).

## STANDARDS
       Process IDs, parent process IDs, process group IDs, and session IDs are specified in POSIX.1.
       The  real, effective, and saved set user and groups IDs, and the supplementary group IDs, are
       specified in POSIX.1.

       The filesystem user and group IDs are a Linux extension.

## NOTES
       Various fields in the _/proc/_pid_/status_ file show the  process  credentials  described  above.
       See [**proc**(5)](https://www.chedong.com/phpMan.php/man/proc/5/markdown) for further information.

       The POSIX threads specification requires that credentials are shared by all of the threads in
       a process.  However, at the kernel level, Linux maintains separate user and group credentials
       for  each thread.  The NPTL threading implementation does some work to ensure that any change
       to user or group credentials (e.g., calls to [**setuid**(2)](https://www.chedong.com/phpMan.php/man/setuid/2/markdown), [**setresuid**(2)](https://www.chedong.com/phpMan.php/man/setresuid/2/markdown)) is carried  through  to
       all of the POSIX threads in a process.  See [**nptl**(7)](https://www.chedong.com/phpMan.php/man/nptl/7/markdown) for further details.

## SEE ALSO
       [**bash**(1)](https://www.chedong.com/phpMan.php/man/bash/1/markdown),  [**csh**(1)](https://www.chedong.com/phpMan.php/man/csh/1/markdown),  [**groups**(1)](https://www.chedong.com/phpMan.php/man/groups/1/markdown),  [**id**(1)](https://www.chedong.com/phpMan.php/man/id/1/markdown), [**newgrp**(1)](https://www.chedong.com/phpMan.php/man/newgrp/1/markdown), [**ps**(1)](https://www.chedong.com/phpMan.php/man/ps/1/markdown), [**runuser**(1)](https://www.chedong.com/phpMan.php/man/runuser/1/markdown), [**setpriv**(1)](https://www.chedong.com/phpMan.php/man/setpriv/1/markdown), [**sg**(1)](https://www.chedong.com/phpMan.php/man/sg/1/markdown), [**su**(1)](https://www.chedong.com/phpMan.php/man/su/1/markdown),
       [**access**(2)](https://www.chedong.com/phpMan.php/man/access/2/markdown), [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown), [**faccessat**(2)](https://www.chedong.com/phpMan.php/man/faccessat/2/markdown), [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown), [**getgroups**(2)](https://www.chedong.com/phpMan.php/man/getgroups/2/markdown), [**getpgrp**(2)](https://www.chedong.com/phpMan.php/man/getpgrp/2/markdown), [**getpid**(2)](https://www.chedong.com/phpMan.php/man/getpid/2/markdown), [**getppid**(2)](https://www.chedong.com/phpMan.php/man/getppid/2/markdown),
       [**getsid**(2)](https://www.chedong.com/phpMan.php/man/getsid/2/markdown),  [**kill**(2)](https://www.chedong.com/phpMan.php/man/kill/2/markdown),  [**setegid**(2)](https://www.chedong.com/phpMan.php/man/setegid/2/markdown),  [**seteuid**(2)](https://www.chedong.com/phpMan.php/man/seteuid/2/markdown),  [**setfsgid**(2)](https://www.chedong.com/phpMan.php/man/setfsgid/2/markdown),  [**setfsuid**(2)](https://www.chedong.com/phpMan.php/man/setfsuid/2/markdown),  [**setgid**(2)](https://www.chedong.com/phpMan.php/man/setgid/2/markdown),   **set‐**
       [**groups**(2)](https://www.chedong.com/phpMan.php/man/groups/2/markdown),  [**setpgid**(2)](https://www.chedong.com/phpMan.php/man/setpgid/2/markdown), [**setresgid**(2)](https://www.chedong.com/phpMan.php/man/setresgid/2/markdown), [**setresuid**(2)](https://www.chedong.com/phpMan.php/man/setresuid/2/markdown), [**setsid**(2)](https://www.chedong.com/phpMan.php/man/setsid/2/markdown), [**setuid**(2)](https://www.chedong.com/phpMan.php/man/setuid/2/markdown), [**waitpid**(2)](https://www.chedong.com/phpMan.php/man/waitpid/2/markdown), **euidac‐**
       [**cess**(3)](https://www.chedong.com/phpMan.php/man/cess/3/markdown),  [**initgroups**(3)](https://www.chedong.com/phpMan.php/man/initgroups/3/markdown),  [**killpg**(3)](https://www.chedong.com/phpMan.php/man/killpg/3/markdown),  [**tcgetpgrp**(3)](https://www.chedong.com/phpMan.php/man/tcgetpgrp/3/markdown),  [**tcgetsid**(3)](https://www.chedong.com/phpMan.php/man/tcgetsid/3/markdown),   [**tcsetpgrp**(3)](https://www.chedong.com/phpMan.php/man/tcsetpgrp/3/markdown),   [**group**(5)](https://www.chedong.com/phpMan.php/man/group/5/markdown),
       [**passwd**(5)](https://www.chedong.com/phpMan.php/man/passwd/5/markdown),  [**shadow**(5)](https://www.chedong.com/phpMan.php/man/shadow/5/markdown), [**capabilities**(7)](https://www.chedong.com/phpMan.php/man/capabilities/7/markdown), [**namespaces**(7)](https://www.chedong.com/phpMan.php/man/namespaces/7/markdown), [**path_resolution**(7)](https://www.chedong.com/phpMan.php/man/pathresolution/7/markdown), [**pid_namespaces**(7)](https://www.chedong.com/phpMan.php/man/pidnamespaces/7/markdown),
       [**pthreads**(7)](https://www.chedong.com/phpMan.php/man/pthreads/7/markdown), [**signal**(7)](https://www.chedong.com/phpMan.php/man/signal/7/markdown), [**system_data_types**(7)](https://www.chedong.com/phpMan.php/man/systemdatatypes/7/markdown), [**unix**(7)](https://www.chedong.com/phpMan.php/man/unix/7/markdown), [**user_namespaces**(7)](https://www.chedong.com/phpMan.php/man/usernamespaces/7/markdown), [**sudo**(8)](https://www.chedong.com/phpMan.php/man/sudo/8/markdown)

Linux man-pages 6.7                          2023-11-19                               [_credentials_(7)](https://www.chedong.com/phpMan.php/man/credentials/7/markdown)
