info > CREDENTIALS

CREDENTIALS(7) Linux Programmer's Manual CREDENTIALS(7)

📛 NAME

credentials - process identifiers

🚀 Quick Reference

🎯 Use Case💻 Command📋 Description
Get process IDgetpid()Returns the unique PID of the calling process
Get parent PIDgetppid()Returns the PID of the parent process
Get process group IDgetpgrp()Returns the PGID of the calling process
Get session IDgetsid()Returns the session ID of the calling process
Get real user IDgetuid()Returns the real user ID of the process
Get effective user IDgeteuid()Returns the effective user ID (used for permissions)
Get real group IDgetgid()Returns the real group ID
Get effective group IDgetegid()Returns the effective group ID
Get supplementary groupsgetgroups()Returns the list of supplementary group IDs
Set user IDsetuid()Modifies real/effective/saved-set user ID
Set effective user IDseteuid()Modifies effective user ID only
Set process groupsetpgid()Sets the process group ID of a process
Create new sessionsetsid()Creates a new session and becomes session leader

📖 DESCRIPTION

🆔 Process ID (PID)

Each process has a unique nonnegative integer identifier that is assigned when the process is created using fork(2). A process can obtain its PID using getpid(2). 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), ptrace(2), setpriority(2), setpgid(2), setsid(2), sigqueue(3), and waitpid(2).

A process's PID is preserved across an execve(2).

👪 Parent process ID (PPID)

A process's parent process ID identifies the process that created this process using fork(2). A process can obtain its PPID using getppid(2). A PPID is represented using the type pid_t.

A process's PPID is preserved across an execve(2).

👥 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), and its process group ID using getpgrp(2).

A child created by fork(2) 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).

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 a 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). 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), which creates a new session whose session ID is the same as the PID of the process that called setsid(2). 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 specified when calling open(2)). 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 terminal (see termios(3)), then only the foreground job may write to the terminal; writes from background job 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, including kill(2), killpg(3), getpriority(2), setpriority(2), ioprio_get(2), ioprio_set(2), waitid(2), and waitpid(2). See also the discussion of the F_GETOWN, F_GETOWN_EX, F_SETOWN, and F_SETOWN_EX operations in fcntl(2).

👤 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:

A child process created by fork(2) inherits copies of its parent's user and groups IDs. During an execve(2), 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 execve(2).

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

🔧 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:

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).

Changes to process user and group IDs can affect the capabilities of the process, as described in capabilities(7).

📜 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 credentials described above. See proc(5) 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), setresuid(2)) is carried through to all of the POSIX threads in a process. See nptl(7) for further details.

🔗 SEE ALSO

📄 COLOPHON

This page is part of release 5.10 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 2020-11-01 CREDENTIALS(7)

CREDENTIALS
📛 NAME 🚀 Quick Reference 📖 DESCRIPTION
🆔 Process ID (PID) 👪 Parent process ID (PPID) 👥 Process group ID and session ID 👤 User and group identifiers 🔧 Modifying process user and group IDs
📜 CONFORMING TO 📝 NOTES 🔗 SEE ALSO 📄 COLOPHON

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 20:19 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!