Permissions are checked against processes, not people. When you run a command, the new process carries user and group IDs, and the kernel uses them to decide what it may open or change.
Real and effective IDs
Each process has several user IDs:
- Real UID: who started it.
- Effective UID: the identity used for most permission checks.
- Saved set-user-ID: a stored copy that lets a program drop privileges for a while and take them back.
Group IDs work the same way, with real, effective and saved values, plus a list of supplementary groups.
For an ordinary command all the user IDs are the same:
$ grep -E '^(Uid|Gid)' /proc/self/status
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000The columns are real, effective, saved and filesystem ID. The last one is a Linux detail that normally follows the effective ID.
When they differ
Start passwd in one terminal and leave it waiting at its prompt. In a second terminal:
$ ps -C passwd -o pid,ruser,euser,comm
PID RUSER EUSER COMMAND
4312 maya root passwdpasswd is a setuid root program. Its real user is still maya, so it knows whose password to change, while its effective user is root, so it can update the password database. Press Ctrl+C in the first terminal to cancel.
Inheritance
A child process gets a copy of its parent's IDs. Your shell passes your identity to everything you start. A child cannot change its parent's IDs.
This explains a common surprise: after an administrator adds you to a group, your existing shells do not have it. Log out and back in to get a new session with the new list. Compare:
$ id
$ id mayaThe first shows the current process. The second looks up the account.
Well-written services start as root only for the steps that need it, then switch to an unprivileged account, so a later bug does less damage. Linux also has capabilities, which split root's power into smaller pieces that can be given separately.
Try it
$ ps -o pid,ruser,euser,comm
$ grep -E '^(Uid|Gid|Groups)' /proc/$$/status$$ is the process ID of your shell. Match the numbers with the output of id. You can explore running processes further in the processes lab.
Check your understanding
Process Permissions
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.