The ability to change the persona of a process can be a source of unintentional privacy violations, or even intentional abuse. Because of the potential for problems, changing persona is restricted to special circumstances.
You can't arbitrarily set your user ID or group ID to anything you want; only privileged processes can do that. Instead, the normal way for a program to change its persona is that it has been set up in advance to change to a particular user or group. This is the function of the setuid and setgid bits of a file's access mode. See section The Mode Bits for Access Permission.
When the setuid bit of an executable file is set, executing that file automatically changes the effective user ID to the user that owns the file. Likewise, executing a file whose setgid bit is set changes the effective group ID to the group of the file. See section Executing a File. Creating a file that changes to a particular user or group ID thus requires full access to that user or group ID.
See section File Attributes, for a more general discussion of file modes and accessibility.
A process can always change its effective user (or group) ID back to its real ID. Programs do this so as to turn off their special privileges when they are not needed, which makes for more robustness.
Go to the first, previous, next, last section, table of contents.