Python Users and Groups: /etc/passwd, /etc/group & id
Linux is a multi-user operating system where every process and file is associated with a User ID (UID) and primary/supplementary Group IDs (GIDs). User identities are stored in `/etc/passwd`, password hashes in `/etc/shadow`, and group memberships in `/etc/group`.
"Users are individual employees in an office building; groups are functional teams (e.g. engineering, finance, security). An employee can belong to multiple teams to gain access to different project rooms."
Deep Dive: How It Works
UID Hierarchy: Root superuser is always UID 0; System service accounts (daemon, www-data) use UIDs 1–999; Regular human users start at UID 1000+.
/etc/passwd Structure: `username:password:UID:GID:comment:home_directory:default_shell`.
The `id` Command: Displays current effective UID, GID, and all secondary groups (e.g. `sudo`, `docker`).
Syntax Blueprint
id # Display current user UID, GID, and groups id -u username # Get specific user UID groups # List current group memberships cat /etc/passwd | head -n 5 # Inspect user database
Use id to inspect active security identities and group memberships.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Adding a user to a group (e.g. docker) and wondering why commands still fail immediately.Why it happens: Group memberships are loaded at login session creation.
How to fix: Run `newgrp docker` or log out and log back in for new group memberships to take effect.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Print Current Numeric UID
Run `id -u` to print the current numeric user ID.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.