// learn Β· linux Β· rhcsa Β· 10 min

Local users and groups.

A user account isn't one thing β€” it's a few lines spread across /etc/passwd, /etc/shadow, and /etc/group, plus a home directory and a mail spool. Read each field, then learn the commands that create, modify, lock, and delete accounts.

Linux local users and groups animated tutorial. Covers /etc/passwd, /etc/shadow, /etc/group fields, useradd, usermod, userdel, passwd, chage, primary vs supplementary groups, and account locking. RHCSA EX200 ready.
// users and groups

A Linux account is a few lines of text plus a home directory. Once you can read /etc/passwd, /etc/shadow, and /etc/group, the management commands stop feeling magic.

// before you start
you should know
  • Β·Comfortable viewing files (cat, less) and basic permissions
  • Β·Know that root is the admin account
  • Β·Helpful: the file-permissions / chmod tool for the next lesson
by the end you'll

Read every field of a passwd/shadow/group line, and run the commands to create, modify, lock, and delete accounts safely.

pace: 10 minutes

account files β€” step 1 / 6 Β· /etc/passwd
/etc/passwdaliceusernamexpassword (x = in shadow)1000UID1000GID (primary group)Alice SmithGECOS (comment)/home/alicehome dir/bin/bashlogin shell

/etc/passwd β€” seven colon-separated fields

Every account has one line in /etc/passwd with seven fields separated by colons: username, password placeholder (almost always 'x'), UID, primary GID, GECOS (a free-text comment, historically the user's full name), home directory, and login shell. This file is world-readable β€” that's fine, because the actual password hash lives elsewhere.

// key insight

The kernel only knows numbers β€” UIDs and GIDs. Usernames and group names are a convenience layer that /etc/passwd and /etc/group map to those numbers. That's why a file copied to another system can suddenly be "owned" by a different user: same UID, different name-to-number mapping.

// exam-ready Β· the account commands & files
$id alice
$getent passwd alice
$useradd -m -s /bin/bash alice
$useradd -r svc
$usermod -aG wheel alice
$usermod -L / -U alice
$userdel -r alice
$passwd alice
$passwd -l / -u alice
$chage -l alice
$chage -M 90 -W 7 alice
$groupadd developers
$gpasswd -a alice developers
$newgrp developers
$/etc/skel
$/etc/login.defs
// check yourself
4 quick questions
Q1

Where is a user's actual hashed password stored?

Q2

You run `usermod -G developers alice` to add alice to the developers group. What's the bug?

Q3

What's the difference between a primary and a supplementary group?

Q4

You want to disable password login for a departing employee but keep their files and audit trail. Best move?

These aren't graded β€” they're just for active recall, which is what actually makes the lesson stick.

πŸ‘₯
// next: what they can touch

chmod calculator

Now that you can create users and groups, decide what they can read and write. Flip permission bits and watch rwx ↔ octal update in lockstep.

open β†’

Read this lesson as text6 chapters Β· quiz answers

  1. 01/etc/passwd β€” seven colon-separated fields

    Every account has one line in /etc/passwd with seven fields separated by colons: username, password placeholder (almost always 'x'), UID, primary GID, GECOS (a free-text comment, historically the user's full name), home directory, and login shell. This file is world-readable β€” that's fine, because the actual password hash lives elsewhere.

  2. 02UID and GID β€” the numbers that actually matter

    The kernel doesn't care about your username β€” it tracks you by UID. UID 0 is root. By convention 1–999 are system/service accounts, and 1000+ are regular humans (1–999 + 1000+ split varies by distro). The fourth field is your PRIMARY group's GID β€” the group new files you create are owned by.

  3. 03/etc/shadow β€” where the password actually lives

    The 'x' in passwd points here. /etc/shadow is readable only by root and holds the hashed password ($6$ = SHA-512) plus password-aging fields: last change date, min days between changes, max days before expiry, warning period, inactive period, and the account-expiry date. This separation is why passwd can be world-readable but your hash isn't.

  4. 04Primary vs supplementary groups

    Your PRIMARY group is the GID in /etc/passwd β€” exactly one. SUPPLEMENTARY groups are extra memberships listed in /etc/group (the last field is a comma-separated member list). You're always 'in' your primary group; supplementary groups grant extra access without changing file ownership defaults. id alice shows all of them at once.

  5. 05Create, modify, delete

    useradd makes the account (and, with -m, the home dir from /etc/skel). usermod changes it β€” note -aG (APPEND to supplementary groups); forgetting the -a and using just -G REPLACES all supplementary groups, a classic way to lock yourself out of sudo. userdel removes it; add -r to also delete the home directory and mail spool.

    • $ useradd -m -s /bin/bash -G wheel alice β€” create alice, home dir, in wheel group
    • $ usermod -aG developers alice β€” APPEND alice to developers (note -a!)
    • $ userdel -r alice β€” delete alice + her home + mail
  6. 06Passwords, aging, and locking

    passwd sets or changes a password. chage manages aging (max days, expiry, etc.) and chage -l alice lists it. To LOCK an account, usermod -L (or passwd -l) prepends a ! to the hash so no password matches β€” the account still exists and key-based SSH may still work. To fully block login, also set the shell to /sbin/nologin.

    • $ passwd alice β€” set/change alice's password
    • $ chage -l alice β€” show password-aging info
    • $ chage -M 90 alice β€” password expires every 90 days
    • $ usermod -L alice β€” lock (disable password login)
    • $ usermod -U alice β€” unlock

Quiz β€” answers

Where is a user's actual hashed password stored?
β†’In /etc/shadow β€” /etc/passwd just has an 'x' placeholder pointing there./etc/passwd is world-readable, so storing the hash there would be a disaster. The 'x' in field 2 means 'look in /etc/shadow', which is readable only by root. /etc/shadow also holds the password-aging fields.
You run usermod -G developers alice to add alice to the developers group. What's the bug?
β†’Without -a, -G REPLACES all of alice's supplementary groups with just 'developers' β€” she loses every other group, including wheel/sudo.-G sets the COMPLETE supplementary group list. Use -aG to APPEND. Dropping the -a is a classic way to accidentally remove yourself from the wheel/sudo group and lose admin access.
What's the difference between a primary and a supplementary group?
β†’Primary is the single GID in /etc/passwd (owns your new files by default); supplementary groups are extra memberships in /etc/group for additional access.You have exactly one primary group (the GID in passwd) β€” files you create are group-owned by it. Supplementary groups (listed in /etc/group) grant extra access. id shows both: 'gid=' is primary, 'groups=' lists all.
You want to disable password login for a departing employee but keep their files and audit trail. Best move?
β†’usermod -L alice (lock the password) and optionally set the shell to /sbin/nologinusermod -L prepends ! to the hash so no password matches, without deleting anything. Setting the shell to /sbin/nologin blocks interactive login entirely. userdel -r would destroy their home and break file ownership/audit.
// more in linux

keep going β€” these pair well with what you just learned.

see all linux β†’

See also

back to RHCSA trackall lessons