CINXE.COM
credentials
<html> <head> <title>credentials</title> <META NAME="KEYWORDS" CONTENT="credentials"> </head> <body BGCOLOR="#ffffff" LINK="#0000ff" VLINK="#0000ff" ALINK="#0000ff" TEXT="#000000"> <center> <h1><b>credentials</b></h1></center> <PRE> <STRONG><A HREF="/man7/CREDENTIALS">CREDENTIALS(7)</A></STRONG> Linux Programmer's Manual <STRONG><A HREF="/man7/CREDENTIALS">CREDENTIALS(7)</A></STRONG> NAME credentials - process identifiers DESCRIPTION Process ID (PID) Each process has a unique nonnegative integer identifier that is as- signed when the process is created using <STRONG><A HREF="/man2/fork">fork(2)</A></STRONG>. A process can obtain its PID using <STRONG><A HREF="/man2/getpid">getpid(2)</A></STRONG>. 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 af- fected by the call, for example: <STRONG><A HREF="/man2/kill">kill(2)</A></STRONG>, <STRONG><A HREF="/man2/ptrace">ptrace(2)</A></STRONG>, <STRONG><A HREF="/man2/setpriority">setpriority(2)</A></STRONG> <STRONG><A HREF="/man2/setpgid">setpgid(2)</A></STRONG>, <STRONG><A HREF="/man2/setsid">setsid(2)</A></STRONG>, <STRONG><A HREF="/man3/sigqueue">sigqueue(3)</A></STRONG>, and <STRONG><A HREF="/man2/waitpid">waitpid(2)</A></STRONG>. A process's PID is preserved across an <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>. Parent process ID (PPID) A process's parent process ID identifies the process that created this process using <STRONG><A HREF="/man2/fork">fork(2)</A></STRONG>. A process can obtain its PPID using <STRONG><A HREF="/man2/getppid">getppid(2)</A></STRONG>. A PPID is represented using the type pid_t. A process's PPID is preserved across an <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>. 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 get- <STRONG><A HREF="/man2/sid">sid(2)</A></STRONG>, and its process group ID using <STRONG><A HREF="/man2/getpgrp">getpgrp(2)</A></STRONG>. A child created by <STRONG><A HREF="/man2/fork">fork(2)</A></STRONG> inherits its parent's session ID and process group ID. A process's session ID and process group ID are preserved across an <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>. Sessions and process groups are abstractions devised to support shell job control. A process group (sometimes called a "job") is a collec- tion of processes that share the same process group ID; the shell cre- ates 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 <STRONG><A HREF="/man2/setpgid">setpgid(2)</A></STRONG>. 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 <STRONG><A HREF="/man2/setsid">setsid(2)</A></STRONG>, which creates a new session whose session ID is the same as the PID of the process that called <STRONG><A HREF="/man2/setsid">setsid(2)</A></STRONG>. The creator of the ses- sion 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 specified when calling <STRONG><A HREF="/man2/open">open(2)</A></STRONG>). A terminal may be the controlling terminal of at most one session. 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 termi- nal (see <STRONG><A HREF="/man3/termios">termios(3)</A></STRONG>), then only the foreground job may write to the terminal; writes from background job cause a SIGTTOU signal to be gen- erated, 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, including <STRONG><A HREF="/man2/kill">kill(2)</A></STRONG>, <STRONG><A HREF="/man3/killpg">killpg(3)</A></STRONG>, <STRONG><A HREF="/man2/getpriority">getpriority(2)</A></STRONG>, set- <STRONG><A HREF="/man2/priority">priority(2)</A></STRONG>, <STRONG><A HREF="/man2/ioprio_get">ioprio_get(2)</A></STRONG>, <STRONG><A HREF="/man2/ioprio_set">ioprio_set(2)</A></STRONG>, <STRONG><A HREF="/man2/waitid">waitid(2)</A></STRONG>, and <STRONG><A HREF="/man2/waitpid">waitpid(2)</A></STRONG>. See also the discussion of the F_GETOWN, F_GETOWN_EX, F_SETOWN, and F_SETOWN_EX operations in <STRONG><A HREF="/man2/fcntl">fcntl(2)</A></STRONG>. 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 (de- fined 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 ge- <STRONG><A HREF="/man2/tuid">tuid(2)</A></STRONG> (<STRONG><A HREF="/man2/getgid">getgid(2)</A></STRONG>). * 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 filesys- tem IDs described below for this task. A process can obtain its ef- fective user (group) ID using <STRONG><A HREF="/man2/geteuid">geteuid(2)</A></STRONG> (<STRONG><A HREF="/man2/getegid">getegid(2)</A></STRONG>). * 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 corre- sponding effective IDs that were set when the program was executed (see <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>). 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 <STRONG><A HREF="/man2/seteuid">seteuid(2)</A></STRONG>, <STRONG><A HREF="/man2/setreuid">setreuid(2)</A></STRONG>, or <STRONG><A HREF="/man2/setresuid">setresuid(2)</A></STRONG>. A set- group-ID program performs the analogous tasks using <STRONG><A HREF="/man2/setegid">setegid(2)</A></STRONG>, se- <STRONG><A HREF="/man2/tregid">tregid(2)</A></STRONG>, or <STRONG><A HREF="/man2/setresgid">setresgid(2)</A></STRONG>. A process can obtain its saved set- user-ID (set-group-ID) using <STRONG><A HREF="/man2/getresuid">getresuid(2)</A></STRONG> (<STRONG><A HREF="/man2/getresgid">getresgid(2)</A></STRONG>). * Filesystem user ID and filesystem group ID (Linux-specific). These IDs, in conjunction with the supplementary group IDs described be- low, are used to determine permissions for accessing files; see <STRONG><A HREF="/man7/path_resolution">path_resolution(7)</A></STRONG> 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 <STRONG><A HREF="/man2/setfsuid">setfsuid(2)</A></STRONG> and <STRONG><A HREF="/man2/setfsgid">setfsgid(2)</A></STRONG>. * Supplementary group IDs. This is a set of additional group IDs that are used for permission checks when accessing files and other shared resources. On Linux kernels before 2.6.4, a process can be a member of up to 32 supplementary groups; since kernel 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 sup- plementary groups of which a process may be a member. A process can obtain its set of supplementary group IDs using <STRONG><A HREF="/man2/getgroups">getgroups(2)</A></STRONG>, and can modify the set using <STRONG><A HREF="/man2/setgroups">setgroups(2)</A></STRONG>. A child process created by <STRONG><A HREF="/man2/fork">fork(2)</A></STRONG> inherits copies of its parent's user and groups IDs. During an <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>, a process's real user and group ID and supplementary group IDs are preserved; the effective and saved set IDs may be changed, as described in <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>. Aside from the purposes noted above, a process's user IDs are also em- ployed in a number of other contexts: * when determining the permissions for sending signals (see <STRONG><A HREF="/man2/kill">kill(2)</A></STRONG>); * when determining the permissions for setting process-scheduling pa- rameters (nice value, real time scheduling policy and priority, CPU affinity, I/O priority) using <STRONG><A HREF="/man2/setpriority">setpriority(2)</A></STRONG>, <STRONG><A HREF="/man2/sched_setaffinity">sched_setaffinity(2)</A></STRONG>, <STRONG><A HREF="/man2/sched_setscheduler">sched_setscheduler(2)</A></STRONG>, <STRONG><A HREF="/man2/sched_setparam">sched_setparam(2)</A></STRONG>, <STRONG><A HREF="/man2/sched_setattr">sched_setattr(2)</A></STRONG>, and io- <STRONG><A HREF="/man2/prio_set">prio_set(2)</A></STRONG>; * when checking resource limits (see <STRONG><A HREF="/man2/getrlimit">getrlimit(2)</A></STRONG>); * when checking the limit on the number of inotify instances that the process may create (see <STRONG><A HREF="/man7/inotify">inotify(7)</A></STRONG>). CONFORMING TO 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 creden- tials described above. See <STRONG><A HREF="/man5/proc">proc(5)</A></STRONG> 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 <STRONG><A HREF="/man2/setuid">setuid(2)</A></STRONG>, <STRONG><A HREF="/man2/setresuid">setresuid(2)</A></STRONG>) is carried through to all of the POSIX threads in a process. See <STRONG><A HREF="/man7/nptl">nptl(7)</A></STRONG> for further details. SEE ALSO <STRONG><A HREF="/man1/bash">bash(1)</A></STRONG>, <STRONG><A HREF="/man1/csh">csh(1)</A></STRONG>, <STRONG><A HREF="/man1/groups">groups(1)</A></STRONG>, <STRONG><A HREF="/man1/id">id(1)</A></STRONG>, <STRONG><A HREF="/man1/newgrp">newgrp(1)</A></STRONG>, <STRONG><A HREF="/man1/ps">ps(1)</A></STRONG>, <STRONG><A HREF="/man1/runuser">runuser(1)</A></STRONG>, set- <STRONG><A HREF="/man1/priv">priv(1)</A></STRONG>, <STRONG><A HREF="/man1/sg">sg(1)</A></STRONG>, <STRONG><A HREF="/man1/su">su(1)</A></STRONG>, <STRONG><A HREF="/man2/access">access(2)</A></STRONG>, <STRONG><A HREF="/man2/execve">execve(2)</A></STRONG>, <STRONG><A HREF="/man2/faccessat">faccessat(2)</A></STRONG>, <STRONG><A HREF="/man2/fork">fork(2)</A></STRONG>, <STRONG><A HREF="/man2/getgroups">getgroups(2)</A></STRONG>, <STRONG><A HREF="/man2/getpgrp">getpgrp(2)</A></STRONG>, <STRONG><A HREF="/man2/getpid">getpid(2)</A></STRONG>, <STRONG><A HREF="/man2/getppid">getppid(2)</A></STRONG>, <STRONG><A HREF="/man2/getsid">getsid(2)</A></STRONG>, <STRONG><A HREF="/man2/kill">kill(2)</A></STRONG>, <STRONG><A HREF="/man2/setegid">setegid(2)</A></STRONG>, <STRONG><A HREF="/man2/seteuid">seteuid(2)</A></STRONG>, <STRONG><A HREF="/man2/setfsgid">setfsgid(2)</A></STRONG>, <STRONG><A HREF="/man2/setfsuid">setfsuid(2)</A></STRONG>, <STRONG><A HREF="/man2/setgid">setgid(2)</A></STRONG>, set- <STRONG><A HREF="/man2/groups">groups(2)</A></STRONG>, <STRONG><A HREF="/man2/setpgid">setpgid(2)</A></STRONG>, <STRONG><A HREF="/man2/setresgid">setresgid(2)</A></STRONG>, <STRONG><A HREF="/man2/setresuid">setresuid(2)</A></STRONG>, <STRONG><A HREF="/man2/setsid">setsid(2)</A></STRONG>, se- <STRONG><A HREF="/man2/tuid">tuid(2)</A></STRONG>, <STRONG><A HREF="/man2/waitpid">waitpid(2)</A></STRONG>, <STRONG><A HREF="/man3/euidaccess">euidaccess(3)</A></STRONG>, <STRONG><A HREF="/man3/initgroups">initgroups(3)</A></STRONG>, <STRONG><A HREF="/man3/killpg">killpg(3)</A></STRONG>, tcgetp- <STRONG><A HREF="/man3/grp">grp(3)</A></STRONG>, <STRONG><A HREF="/man3/tcgetsid">tcgetsid(3)</A></STRONG>, <STRONG><A HREF="/man3/tcsetpgrp">tcsetpgrp(3)</A></STRONG>, <STRONG><A HREF="/man5/group">group(5)</A></STRONG>, <STRONG><A HREF="/man5/passwd">passwd(5)</A></STRONG>, <STRONG><A HREF="/man5/shadow">shadow(5)</A></STRONG>, ca- <STRONG><A HREF="/man7/pabilities">pabilities(7)</A></STRONG>, <STRONG><A HREF="/man7/namespaces">namespaces(7)</A></STRONG>, <STRONG><A HREF="/man7/path_resolution">path_resolution(7)</A></STRONG>, <STRONG><A HREF="/man7/pid_namespaces">pid_namespaces(7)</A></STRONG>, <STRONG><A HREF="/man7/pthreads">pthreads(7)</A></STRONG>, <STRONG><A HREF="/man7/signal">signal(7)</A></STRONG>, <STRONG><A HREF="/man7/unix">unix(7)</A></STRONG>, <STRONG><A HREF="/man7/user_namespaces">user_namespaces(7)</A></STRONG>, <STRONG><A HREF="/man8/sudo">sudo(8)</A></STRONG> COLOPHON This page is part of release 5.05 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2019-08-02 <STRONG><A HREF="/man7/CREDENTIALS">CREDENTIALS(7)</A></STRONG></PRE> <center> <h6>Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2025 <a href="http://www.he.net">Hurricane Electric</a>. All Rights Reserved.</h6></center> </body> </html>