Identity and Sessions
Quick answer
Linux associates running processes with numeric user and group identities. Your login name, effective identity and a recorded login session answer different questions; knowing which one you need prevents misleading permission diagnoses.
Prepare the practice environment
Use the chapter fixture described in lab-fixtures/users/README.md. Run setup as a normal user in a disposable Linux environment, enter the printed directory, check pwd, and run export LC_ALL=C; umask 022. Every local example assumes a fresh fixture; examples explicitly marked VM ONLY require an authorized snapshot-backed VM and must not be run in the ordinary fixture. Commands omit the terminal prompt; outputs below are not commands.
How it works
The real UID records a process identity; the effective UID is used for many permission decisions (Linux also has filesystem IDs and capabilities). A process has a primary group and may have supplementary groups. id without a username examines the current process credentials; id USER looks up account information, which can differ from an already running session. whoami reports the effective user name, while who and w consult session records and may omit containers, terminal tabs or services. A login session is not the same as a process.
For troubleshooting, ask two separate questions: which credentials does the process have now, and what account membership does the configured identity database currently report? id answers the first for the calling context, while id USER performs a named lookup. A group change may be visible in the lookup before a new login obtains the updated supplementary groups. A terminal window is not necessarily a recorded login session.
Try the examples
Manual read-only inspection; output varies. Match id -u to the UID of the effective account; never share actual group memberships unnecessarily.
Manual example; not executed locally. Follow its stated environment restrictions.
test "$(id -un)" = "$(whoami)" && printf "identity matches\n"Both commands resolve the effective user name. The test reports only whether they agree.
Expected stdout:
identity matchesManual read-only inspection: zero rows can be normal; do not conclude that no processes are running. The output may include session or host details; keep it private.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Do not treat $USER, a prompt, or an empty who listing as proof of effective permissions. Inspect credentials with id and check the actual resource.
Practice
Compare id -u, id -ru, id -g, and id -G locally; explain why a new group membership may not appear in an old session. Do not copy identity output into public reports.
Related references
Study: id, whoami, who, w, groups. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Identity and sessions — Knowledge Check
Apply the lesson concepts to the controlled account fixture.
Which command reports the effective user name?
Which command inspects current process group IDs?
An empty who listing proves what?
Why may id USER differ from id without USER?