ruby 进程的 pid、ppid、uid、euid、gid 和 egid 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30493424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between a Process' pid, ppid, uid, euid, gid and egid?
提问by Joshua Pinter
Context: I'm getting the current Ruby process ID.
上下文:我正在获取当前的 Ruby 进程 ID。
Process.pid #=> 95291
Process.ppid #=> 95201
Process.uid #=> 501
Process.gid #=> 20
Process.euid #=> 501
Process.egid #=> 20
回答by Linuxios
In order:
为了:
pid: The is the process ID (PID) of the process you call theProcess.pidmethod in.ppid: The PID of the parent process (the process that spawned the current one). For example, if you runruby test.rbin 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 effectiveuser 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 asuid, but can be different with commands likesudo.gid: The UNIX group ID the program is running under.egid: Likeeuid, but for groups.
pid: 是您调用该Process.pid方法的进程的进程 ID (PID) 。ppid:父进程的PID(产生当前进程的进程)。例如,如果您ruby test.rb在 bash shell 中运行,则该进程中的 PPID 将是 Bash 的 PID。uid: 进程在其下运行的用户的 UNIX ID。euid:进程在其下运行的有效用户 ID。EUID 根据允许具有此 UID 的用户执行的操作来确定允许程序执行的操作。通常与 相同uid,但可以与sudo.gid:程序在其下运行的 UNIX 组 ID。egid: 喜欢euid,但对于团体。
回答by Bruce Wayne
PID:
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.
在 Linux 中,存储在磁盘上的可执行文件称为程序,加载到内存中并运行的程序称为进程。当一个进程启动时,它被赋予一个称为进程 ID (PID) 的唯一编号,用于向系统标识该进程。例如,如果您需要终止一个进程,您可以通过其 PID 来引用它。
PPID:
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.
除了唯一的进程 ID 之外,每个进程都被分配了一个父进程 ID (PPID),用于说明哪个进程启动了它。PPID 是进程的父进程的 PID。
例如,如果进程 1 的 PID 为 101 启动了一个名为进程 2 的进程,那么进程 2 将被赋予一个唯一的 PID,例如 3240,但它会被赋予 101 的 PPID。这是一种父子关系。单个父进程可能会产生多个子进程,每个子进程都有唯一的 PID,但都共享相同的 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.
类 Unix 操作系统通过称为用户标识符的值在内核中识别用户,通常缩写为 UID 或用户 ID。UID 与 GID 和其他访问控制标准一起用于确定用户可以访问哪些系统资源。密码文件将文本用户名映射到 UID,但在内核中,仅使用 UID。
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.
进程的有效 UID (euid) 用于大多数访问检查。它还用作该进程创建的文件的所有者。
GID:
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.
组标识符,通常缩写为 GID,是用于表示特定组的数值。GID 的值范围因系统而异;至少,GID 可以介于 0 到 32,767 之间,但有一个限制:超级用户的登录组必须具有 GID 0。
EGID:
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.
进程的有效 GID (egid) 也会影响访问控制,也可能会影响文件创建,具体取决于正在使用的特定内核实现的语义以及可能使用的挂载选项。
Refer these articles for more information:
有关更多信息,请参阅这些文章:

