Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a Process' pid, ppid, uid, euid, gid and egid?

Tags:

process

ruby

pid

Context: I'm getting the current Ruby process ID.

Process.pid  #=> 95291

Process.ppid #=> 95201

Process.uid  #=> 501

Process.gid  #=> 20

Process.euid #=> 501

Process.egid #=> 20
like image 925
Joshua Pinter Avatar asked May 27 '15 21:05

Joshua Pinter


People also ask

What is the difference between PID and PPID?

pid : The is the process ID (PID) of the process you call the Process. pid method in. ppid : The PID of the parent process (the process that spawned the current one). For example, if you run ruby test.

What is PPID which process has PPID 1?

The AIX Operating System implements a hierarchy of processes in that each child process has a parent process that created the child. The parent process is indicated by the PPID (Parent Process ID) in the output from the ps -ef command. On AIX there are two types of processes - regular processes and kernel processes.

What is process GID?

Sets the process group ID (PGID) of a process within the session of the calling process, so you can reassign a process to a different process group, or start a new process group with the specified process as its group leader. pid_t pid is the process ID (PID) of the process whose PGID you want to change.

What is PID UID and GID Linux?

User and Group Privileges Each process has some form of associated Process Identifier, (PID) through which it may be manipulated. The process also carries the User Identifier (UID) of the person who initiated the process and will also have group identifier (GID).


2 Answers

In order:

  • pid: The is the process ID (PID) of the process you call the Process.pid method in.
  • ppid: The PID of the parent process (the process that spawned the current one). For example, if you run ruby test.rb in a bash shell, PPID in that process would be the PID of Bash.
  • uid: The UNIX ID of the user the process is running under.
  • euid: The effective user ID that the process is running under. The EUID determines what a program is allowed to do, based on what the user with this UID is allowed to do. Typically the same as uid, but can be different with commands like sudo.
  • gid: The UNIX group ID the program is running under.
  • egid: Like euid, but for groups.
like image 66
Linuxios Avatar answered Oct 17 '22 21:10

Linuxios


PID:

In Linux, an executable stored on disk is called a program, and a program loaded into memory and running is called a process. When a process is started, it is given a unique number called process ID (PID) that identifies that process to the system. If you ever need to kill a process, for example, you can refer to it by its PID.

PPID:

In addition to a unique process ID, each process is assigned a parent process ID (PPID) that tells which process started it. The PPID is the PID of the process’s parent.

For example, if process1 with a PID of 101 starts a process named process2, then process2 will be given a unique PID, such as 3240, but it will be given the PPID of 101. It’s a parent-child relationship. A single parent process may spawn several child processes, each with a unique PID but all sharing the same PPID.

UID:

Unix-like operating systems identify users within the kernel by a value called a user identifier, often abbreviated to UID or User ID. The UID, along with the GID and other access control criteria, is used to determine which system resources a user can access. The password file maps textual usernames to UIDs, but in the kernel, only UID's are used.

EUID:

The effective UID (euid) of a process is used for most access checks. It is also used as the owner for files created by that process.

GID:

A group identifier, often abbreviated to GID, is a numeric value used to represent a specific group. The range of values for a GID varies amongst different systems; at the very least, a GID can be between 0 and 32,767, with one restriction: the login group for the superuser must have GID 0.

EGID:

The effective GID (egid) of a process also affects access control and may also affect file creation, depending on the semantics of the specific kernel implementation in use and possibly the mount options used.

Refer these articles for more information:

  1. What are PID and PPID?
  2. Meaning of PID, PPID and TGID
  3. User identifier
  4. Group identifier
like image 40
Srini Avatar answered Oct 17 '22 22:10

Srini