{
    "content": [
        {
            "type": "text",
            "text": "# CREDENTIALS(7) (man)\n\n**Summary:** credentials - process identifiers\n\n## See Also\n\n- bash(1)\n- csh(1)\n- groups(1)\n- id(1)\n- newgrp(1)\n- ps(1)\n- runuser(1)\n- setpriv(1)\n- sg(1)\n- su(1)\n- access(2)\n- execve(2)\n- faccessat(2)\n- fork(2)\n- getgroups(2)\n- getpgrp(2)\n- getpid(2)\n- getppid(2)\n- getsid(2)\n- kill(2)\n- setegid(2)\n- seteuid(2)\n- setfsgid(2)\n- setfsuid(2)\n- setgid(2)\n- groups(2)\n- setpgid(2)\n- setresgid(2)\n- setresuid(2)\n- setsid(2)\n- setuid(2)\n- waitpid(2)\n- cess(3)\n- initgroups(3)\n- killpg(3)\n- tcgetpgrp(3)\n- tcgetsid(3)\n- tcsetpgrp(3)\n- group(5)\n- passwd(5)\n- shadow(5)\n- capabilities(7)\n- namespaces(7)\n- pathresolution(7)\n- pidnamespaces(7)\n- pthreads(7)\n- signal(7)\n- systemdatatypes(7)\n- unix(7)\n- usernamespaces(7)\n- sudo(8)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (1 lines) — 5 subsections\n  - Process ID (PID) (10 lines)\n  - Parent process ID (PPID) (5 lines)\n  - Process group ID and session ID (41 lines)\n  - User and group identifiers (60 lines)\n  - Modifying process user and group IDs (28 lines)\n- **CONFORMING TO** (4 lines)\n- **NOTES** (9 lines)\n- **SEE ALSO** (8 lines)\n- **COLOPHON** (7 lines)\n\n## Full Content\n\n### NAME\n\ncredentials - process identifiers\n\n### DESCRIPTION\n\n#### Process ID (PID)\n\nEach process has a unique nonnegative integer identifier that is assigned when the process is\ncreated using fork(2).  A process can obtain its PID using getpid(2).  A PID  is  represented\nusing the type pidt (defined in <sys/types.h>).\n\nPIDs  are  used  in a range of system calls to identify the process affected by the call, for\nexample: kill(2), ptrace(2), setpriority(2) setpgid(2),  setsid(2),  sigqueue(3),  and  wait‐‐\npid(2).\n\nA process's PID is preserved across an execve(2).\n\n#### Parent process ID (PPID)\n\nA process's parent process ID identifies the process that created this process using fork(2).\nA process can obtain its PPID using getppid(2).  A PPID is represented using the type pidt.\n\nA process's PPID is preserved across an execve(2).\n\n#### Process group ID and session ID\n\nEach process has a session ID and a process group ID, both represented using the type  pidt.\nA  process  can  obtain  its session ID using getsid(2), and its process group ID using getp‐‐\ngrp(2).\n\nA child created by fork(2) inherits  its  parent's  session  ID  and  process  group  ID.   A\nprocess's session ID and process group ID are preserved across an execve(2).\n\nSessions and process groups are abstractions devised to support shell job control.  A process\ngroup (sometimes called a \"job\") is a collection of processes that  share  the  same  process\ngroup  ID;  the  shell creates a new process group for the process(es) used to execute single\ncommand or pipeline (e.g., the two processes created to execute  the  command  \"ls | wc\"  are\nplaced in the same process group).  A process's group membership can be set using setpgid(2).\nThe process whose process ID is the same as its process group ID is the process group  leader\nfor that group.\n\nA session is a collection of processes that share the same session ID.  All of the members of\na process group also have the same session ID (i.e., all of the members of  a  process  group\nalways  belong  to  the  same session, so that sessions and process groups form a strict two-\nlevel hierarchy of processes.)  A new session is created  when  a  process  calls  setsid(2),\nwhich  creates  a  new  session  whose  session ID is the same as the PID of the process that\ncalled setsid(2).  The creator of the session is called the session leader.\n\nAll of the processes in a session share a controlling terminal.  The controlling terminal  is\nestablished when the session leader first opens a terminal (unless the ONOCTTY flag is spec‐\nified when calling open(2)).  A terminal may be the controlling terminal of at most one  ses‐\nsion.\n\nAt most one of the jobs in a session may be the foreground job; other jobs in the session are\nbackground jobs.  Only the foreground job may read from the terminal; when a process  in  the\nbackground  attempts  to  read from the terminal, its process group is sent a SIGTTIN signal,\nwhich suspends the job.  If the TOSTOP flag has been set for the terminal  (see  termios(3)),\nthen  only  the  foreground job may write to the terminal; writes from background job cause a\nSIGTTOU signal to be generated, which suspends the job.  When terminal keys that  generate  a\nsignal (such as the interrupt key, normally control-C) are pressed, the signal is sent to the\nprocesses in the foreground job.\n\nVarious system calls and library functions may operate on all members of a process group, in‐\ncluding  kill(2),  killpg(3),  getpriority(2),  setpriority(2), ioprioget(2), ioprioset(2),\nwaitid(2), and waitpid(2).  See also the discussion of the FGETOWN,  FGETOWNEX,  FSETOWN,\nand FSETOWNEX operations in fcntl(2).\n\n#### User and group identifiers\n\nEach process has various associated user and group IDs.  These IDs are integers, respectively\nrepresented using the types uidt and gidt (defined in <sys/types.h>).\n\nOn Linux, each process has the following user and group identifiers:\n\n*  Real user ID and real group ID.  These IDs determine who owns the process.  A process  can\nobtain its real user (group) ID using getuid(2) (getgid(2)).\n\n*  Effective  user  ID and effective group ID.  These IDs are used by the kernel to determine\nthe permissions that the process will have when accessing shared resources such as message\nqueues, shared memory, and semaphores.  On most UNIX systems, these IDs also determine the\npermissions when accessing files.  However, Linux uses the filesystem IDs described  below\nfor this task.  A process can obtain its effective user (group) ID using geteuid(2) (gete‐‐\ngid(2)).\n\n*  Saved set-user-ID and saved set-group-ID.  These IDs are  used  in  set-user-ID  and  set-\ngroup-ID programs to save a copy of the corresponding effective IDs that were set when the\nprogram was executed (see execve(2)).  A set-user-ID program can assume  and  drop  privi‐\nleges  by  switching  its  effective user ID back and forth between the values in its real\nuser ID and saved set-user-ID.  This switching  is  done  via  calls  to  seteuid(2),  se‐‐\ntreuid(2),  or  setresuid(2).   A  set-group-ID program performs the analogous tasks using\nsetegid(2), setregid(2), or setresgid(2).  A process  can  obtain  its  saved  set-user-ID\n(set-group-ID) using getresuid(2) (getresgid(2)).\n\n*  Filesystem  user  ID  and filesystem group ID (Linux-specific).  These IDs, in conjunction\nwith the supplementary group IDs described below, are used to  determine  permissions  for\naccessing  files; see pathresolution(7) for details.  Whenever a process's effective user\n(group) ID is changed, the kernel also automatically changes the filesystem  user  (group)\nID  to  the same value.  Consequently, the filesystem IDs normally have the same values as\nthe corresponding effective ID, and the semantics for file-permission checks are thus  the\nsame on Linux as on other UNIX systems.  The filesystem IDs can be made to differ from the\neffective IDs by calling setfsuid(2) and setfsgid(2).\n\n*  Supplementary group IDs.  This is a set of additional group IDs that are used for  permis‐\nsion  checks  when  accessing  files  and other shared resources.  On Linux kernels before\n2.6.4, a process can be a member of up to 32 supplementary groups; since kernel  2.6.4,  a\nprocess   can   be   a   member   of   up   to   65536  supplementary  groups.   The  call\nsysconf(SCNGROUPSMAX) can be used to determine the number of  supplementary  groups  of\nwhich  a process may be a member.  A process can obtain its set of supplementary group IDs\nusing getgroups(2).\n\nA child process created by fork(2) inherits copies of its parent's user and groups IDs.  Dur‐\ning  an  execve(2),  a  process's real user and group ID and supplementary group IDs are pre‐\nserved; the effective and saved set IDs may be changed, as described in execve(2).\n\nAside from the purposes noted above, a process's user IDs are also employed in  a  number  of\nother contexts:\n\n*  when determining the permissions for sending signals (see kill(2));\n\n*  when  determining  the  permissions for setting process-scheduling parameters (nice value,\nreal time scheduling policy and priority, CPU  affinity,  I/O  priority)  using  setprior‐‐\nity(2),  schedsetaffinity(2), schedsetscheduler(2), schedsetparam(2), schedsetattr(2),\nand ioprioset(2);\n\n*  when checking resource limits (see getrlimit(2));\n\n*  when checking the limit on the number of inotify instances that  the  process  may  create\n(see inotify(7)).\n\n#### Modifying process user and group IDs\n\nSubject to rules described in the relevant manual pages, a process can use the following APIs\nto modify its user and group IDs:\n\nsetuid(2) (setgid(2))\nModify the process's real (and possibly effective and saved-set) user (group) IDs.\n\nseteuid(2) (setegid(2))\nModify the process's effective user (group) ID.\n\nsetfsuid(2) (setfsgid(2))\nModify the process's filesystem user (group) ID.\n\nsetreuid(2) (setregid(2))\nModify the process's real and effective (and possibly saved-set) user (group) IDs.\n\nsetresuid(2) (setresgid(2))\nModify the process's real, effective, and saved-set user (group) IDs.\n\nsetgroups(2)\nModify the process's supplementary group list.\n\nAny changes to a process's effective user (group) ID are automatically carried  over  to  the\nprocess's  filesystem user (group) ID.  Changes to a process's effective user or group ID can\nalso affect the process \"dumpable\" attribute, as described in prctl(2).\n\nChanges to process user and group IDs can affect the capabilities  of  the  process,  as  de‐\nscribed in capabilities(7).\n\n### CONFORMING TO\n\nProcess IDs, parent process IDs, process group IDs, and session IDs are specified in POSIX.1.\nThe real, effective, and saved set user and groups IDs, and the supplementary group IDs,  are\nspecified in POSIX.1.  The filesystem user and group IDs are a Linux extension.\n\n### NOTES\n\nVarious  fields  in the /proc/[pid]/status file show the process credentials described above.\nSee proc(5) for further information.\n\nThe POSIX threads specification requires that credentials are shared by all of the threads in\na process.  However, at the kernel level, Linux maintains separate user and group credentials\nfor each thread.  The NPTL threading implementation does some work to ensure that any  change\nto  user  or group credentials (e.g., calls to setuid(2), setresuid(2)) is carried through to\nall of the POSIX threads in a process.  See nptl(7) for further details.\n\n### SEE ALSO\n\nbash(1), csh(1), groups(1), id(1), newgrp(1), ps(1), runuser(1),  setpriv(1),  sg(1),  su(1),\naccess(2), execve(2), faccessat(2), fork(2), getgroups(2), getpgrp(2), getpid(2), getppid(2),\ngetsid(2),  kill(2),  setegid(2),  seteuid(2),  setfsgid(2),  setfsuid(2),  setgid(2),   set‐‐\ngroups(2),  setpgid(2), setresgid(2), setresuid(2), setsid(2), setuid(2), waitpid(2), euidac‐‐\ncess(3),  initgroups(3),  killpg(3),  tcgetpgrp(3),  tcgetsid(3),   tcsetpgrp(3),   group(5),\npasswd(5),  shadow(5), capabilities(7), namespaces(7), pathresolution(7), pidnamespaces(7),\npthreads(7), signal(7), systemdatatypes(7), unix(7), usernamespaces(7), sudo(8)\n\n### COLOPHON\n\nThis page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-11-01                               CREDENTIALS(7)\n\n"
        }
    ],
    "structuredContent": {
        "command": "CREDENTIALS",
        "section": "7",
        "mode": "man",
        "summary": "credentials - process identifiers",
        "synopsis": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "bash",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/bash/1/json"
            },
            {
                "name": "csh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/csh/1/json"
            },
            {
                "name": "groups",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/groups/1/json"
            },
            {
                "name": "id",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/id/1/json"
            },
            {
                "name": "newgrp",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/newgrp/1/json"
            },
            {
                "name": "ps",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ps/1/json"
            },
            {
                "name": "runuser",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/runuser/1/json"
            },
            {
                "name": "setpriv",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/setpriv/1/json"
            },
            {
                "name": "sg",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/sg/1/json"
            },
            {
                "name": "su",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
            },
            {
                "name": "access",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/access/2/json"
            },
            {
                "name": "execve",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/execve/2/json"
            },
            {
                "name": "faccessat",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/faccessat/2/json"
            },
            {
                "name": "fork",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/fork/2/json"
            },
            {
                "name": "getgroups",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getgroups/2/json"
            },
            {
                "name": "getpgrp",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getpgrp/2/json"
            },
            {
                "name": "getpid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getpid/2/json"
            },
            {
                "name": "getppid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getppid/2/json"
            },
            {
                "name": "getsid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getsid/2/json"
            },
            {
                "name": "kill",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/kill/2/json"
            },
            {
                "name": "setegid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setegid/2/json"
            },
            {
                "name": "seteuid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/seteuid/2/json"
            },
            {
                "name": "setfsgid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setfsgid/2/json"
            },
            {
                "name": "setfsuid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setfsuid/2/json"
            },
            {
                "name": "setgid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setgid/2/json"
            },
            {
                "name": "groups",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/groups/2/json"
            },
            {
                "name": "setpgid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setpgid/2/json"
            },
            {
                "name": "setresgid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setresgid/2/json"
            },
            {
                "name": "setresuid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setresuid/2/json"
            },
            {
                "name": "setsid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setsid/2/json"
            },
            {
                "name": "setuid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setuid/2/json"
            },
            {
                "name": "waitpid",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/waitpid/2/json"
            },
            {
                "name": "cess",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/cess/3/json"
            },
            {
                "name": "initgroups",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/initgroups/3/json"
            },
            {
                "name": "killpg",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/killpg/3/json"
            },
            {
                "name": "tcgetpgrp",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/tcgetpgrp/3/json"
            },
            {
                "name": "tcgetsid",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/tcgetsid/3/json"
            },
            {
                "name": "tcsetpgrp",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/tcsetpgrp/3/json"
            },
            {
                "name": "group",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/group/5/json"
            },
            {
                "name": "passwd",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/passwd/5/json"
            },
            {
                "name": "shadow",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/shadow/5/json"
            },
            {
                "name": "capabilities",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/capabilities/7/json"
            },
            {
                "name": "namespaces",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/namespaces/7/json"
            },
            {
                "name": "pathresolution",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/pathresolution/7/json"
            },
            {
                "name": "pidnamespaces",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/pidnamespaces/7/json"
            },
            {
                "name": "pthreads",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/pthreads/7/json"
            },
            {
                "name": "signal",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/signal/7/json"
            },
            {
                "name": "systemdatatypes",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/systemdatatypes/7/json"
            },
            {
                "name": "unix",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/unix/7/json"
            },
            {
                "name": "usernamespaces",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/usernamespaces/7/json"
            },
            {
                "name": "sudo",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/sudo/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Process ID (PID)",
                        "lines": 10
                    },
                    {
                        "name": "Parent process ID (PPID)",
                        "lines": 5
                    },
                    {
                        "name": "Process group ID and session ID",
                        "lines": 41
                    },
                    {
                        "name": "User and group identifiers",
                        "lines": 60
                    },
                    {
                        "name": "Modifying process user and group IDs",
                        "lines": 28
                    }
                ]
            },
            {
                "name": "CONFORMING TO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ]
    }
}