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

Joshua Pinter picture Joshua Pinter · May 27, 2015 · Viewed 31.9k times · Source

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

Answer

Linuxios picture Linuxios · May 27, 2015

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.