Objectives
What the exam tests
- Create, delete, and modify local user accounts
- Change passwords and configure password aging policies with
chage - Create, delete, and modify local groups and group memberships
- Configure superuser access using
sudoandvisudo - Understand and interpret
/etc/passwd,/etc/shadow,/etc/group - Set UID, GID, home directory, shell, and account expiry at creation
- Lock and unlock user accounts
- Create system accounts for services (no login shell, no home)
- Configure default values for new user creation via
/etc/login.defs
User and group management appears on every RHCSA exam. Expect multi-step tasks: create a user, set a password, assign to a group, configure aging, and grant sudo — all in one scenario.
Coverage weight by topic
Configuration files
/etc/passwd — user account database
Seven colon-separated fields. World-readable — passwords are not stored here.
| Field | Meaning | Notes |
|---|---|---|
| Username | Login name | Max 32 chars; lowercase recommended |
| Password | x = stored in /etc/shadow | Never a real password here |
| UID | User ID number | 0=root; 1–999=system; 1000+=regular users |
| GID | Primary group ID | References /etc/group |
| GECOS | Full name / comment | Displayed by finger, set with -c |
| Home dir | User's home directory path | Created by useradd -m |
| Shell | Login shell | /sbin/nologin or /bin/false disables login |
/etc/shadow — password and aging database
Nine colon-separated fields. Readable only by root. This is where hashed passwords and aging policy are stored.
| Field # | Meaning | Set with |
|---|---|---|
| 1 — Username | Login name (matches /etc/passwd) | — |
| 2 — Hash | Hashed password. ! = locked; !! = never set | passwd |
| 3 — Last change | Days since epoch when password was last changed | chage -d |
| 4 — Min days | Minimum days between password changes | chage -m |
| 5 — Max days | Maximum days before password must change | chage -M |
| 6 — Warn days | Days of warning before password expires | chage -W |
| 7 — Inactive | Days after expiry before account is disabled | chage -I |
| 8 — Expire | Date (days since epoch) when account expires | chage -E |
| 9 — Reserved | Unused | — |
/etc/group and /etc/gshadow
| Field | Meaning |
|---|---|
| Group name | Name of the group |
| Password | x = stored in /etc/gshadow (group passwords are rarely used) |
| GID | Group ID number. System groups: 0–999; user groups: 1000+ |
| Member list | Comma-separated list of supplementary members. Primary group members are NOT listed here. |
A user's primary group is set in /etc/passwd field 4 (GID). The user is NOT listed in /etc/group for their primary group — only supplementary memberships appear there.
/etc/login.defs — new account defaults
Changes to /etc/login.defs only affect newly created accounts. Existing accounts are not retroactively updated.
/etc/skel — new user home template
User account management
useradd — creating accounts
After creating a user, always set a password with passwd username. An account without a password has !! in /etc/shadow and cannot log in at all.
usermod — modifying accounts
usermod -G groups user without -a. It silently replaces all supplementary group memberships. Always use usermod -aG groups user.userdel — removing accounts
Always verify whether you should preserve or remove the home directory. On the exam, read the task carefully — it may say "remove the user's home directory" or "preserve the user's files."
Querying user information
Passwords and aging
passwd — setting and managing passwords
chage — full aging policy control
| chage flag | shadow field | Effect |
|---|---|---|
-d DAYS | Field 3 | Set last change date (0 = force change on next login) |
-m DAYS | Field 4 | Minimum days between password changes |
-M DAYS | Field 5 | Maximum days before password must change |
-W DAYS | Field 6 | Warning days before password expires |
-I DAYS | Field 7 | Inactive days — lock account after this many days past expiry |
-E DATE | Field 8 | Account expiry date (YYYY-MM-DD or -1 for never) |
-l | All | List (display) all aging information |
Password hash formats in /etc/shadow
Group management
groupadd, groupmod, groupdel
Primary vs supplementary groups
Primary group
- Every user has exactly one primary group
- Stored in
/etc/passwdfield 4 (GID) - New files created by user are owned by this group
- User is NOT listed in
/etc/groupfor primary group - Change with
usermod -g groupname user - Switch for session with
newgrp groupname
Supplementary groups
- A user can belong to many supplementary groups
- Stored in
/etc/groupmember list field 4 - Grant additional resource access
- Add with
usermod -aG group user(use-a!) - Remove with
gpasswd -d user group - Changes take effect at next login
After adding a user to a supplementary group, they must log out and back in (or run newgrp groupname) for the change to take effect in their current session.
newgrp — switch active group in session
sudo configuration
sudo overview and visudo
sudo allows authorized users to run commands as root (or another user) without knowing the root password. Configuration lives in /etc/sudoers — always edited with visudo to prevent syntax errors.
A syntax error in /etc/sudoers can prevent any user from using sudo, including root. Always use visudo. If you do break it, boot to rescue mode and fix the file.
sudoers rule syntax
/etc/sudoers.d/ — drop-in files
Drop-in files in /etc/sudoers.d/ survive package updates to /etc/sudoers. They must have permissions 0440 (or stricter) and filenames must not contain ~ or . to be included.
The wheel group — quickest sudo grant
su vs sudo — when to use each
| Command | Requires | Effect | Audit trail |
|---|---|---|---|
su - | Root password | Full root login shell (new session) | Only login recorded |
su - alice | alice's password (or root) | Full login shell as alice | Only login recorded |
sudo command | User's own password + sudoers rule | Run single command as root | Full command logged |
sudo -i | User's own password + sudoers rule | Interactive root shell via sudo | All commands logged |
sudo -l | User's own password | List allowed sudo commands | — |
Prefer sudo over su in production environments — every sudo invocation is logged to /var/log/secure with the username and full command, creating an auditable trail.
Cheat sheet
Most-tested commands — quick reference
useradd -m -s /bin/bash aliceuseradd -u 1500 -G wheel aliceuseradd -r -s /sbin/nologin svcpasswd aliceecho "Pass1" | passwd --stdin alicechage -d 0 alicechage -M 90 alicechage -E "2027-01-01" alicechage -l aliceusermod -L aliceusermod -U aliceusermod -s /sbin/nologin aliceusermod -aG wheel aliceusermod -g devs aliceusermod -l newname aliceuserdel -r aliceid alicegetent passwd alicegroupadd -g 2001 devsgpasswd -a alice devsgpasswd -d alice devsgetent group devsvisudousermod -aG wheel alicesudo -lecho "alice ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/aliceuseradd / usermod flag comparison
| Flag | useradd meaning | usermod meaning |
|---|---|---|
-u UID | Set UID for new account | Change existing UID |
-g group | Set primary group | Change primary group |
-G groups | Set supplementary groups | Replaces all supplementary groups |
-a | N/A | Append — must combine with -G |
-aG groups | N/A | Appends to supplementary groups |
-s shell | Set login shell | Change login shell |
-d dir | Set home directory path | Change home path (use -m to move) |
-m | Create home if missing | Move home directory contents |
-c text | Set GECOS comment | Change GECOS comment |
-e date | Set account expiry | Change account expiry |
-r | System account (low UID) | N/A |
-M | Do not create home dir | N/A |
-L | N/A | Lock account (add ! to hash) |
-U | N/A | Unlock account (remove !) |
-l name | N/A | Rename login name |
Full user setup — exam template
Practice quiz
Question 1 of 8
User alice is in groups alice, devs, and ops. You run usermod -G wheel alice. What is the result?
usermod -G wheel alice without -a replaces all supplementary group memberships with just wheel. Alice loses membership in devs and ops. Her primary group (alice) is unaffected. Always use usermod -aG wheel alice to append safely.Question 2 of 8
You need user bob to change his password the next time he logs in, but not force it today. Which command achieves this?
chage -d 0 bob sets the "last password change" date to day 0 (January 1, 1970), making the password immediately expired. On next login the system will require bob to set a new password before proceeding. chage -M 0 sets max days to 0 which means the password is always instantly expired — similar effect but a different field. usermod -L locks the account, preventing login entirely. chage -e 0 would expire the account itself.Question 3 of 8
Which file stores hashed passwords and password aging policy?
/etc/shadow stores the hashed password (field 2) and all aging fields (min days, max days, warn days, inactive days, expiry date). It is readable only by root. /etc/passwd contains account metadata but stores only x for the password field. /etc/login.defs stores aging defaults for new accounts, not per-user data.Question 4 of 8
You create a drop-in sudo rule file at /etc/sudoers.d/alice. The file has permissions 0644. What happens when alice tries to use sudo?
0440 or stricter (e.g., 0400). A file with world-readable permissions (0644) is considered insecure and sudo will refuse to parse it with an error like "sudo: /etc/sudoers.d/alice is world-readable". Always set chmod 0440 /etc/sudoers.d/filename.Question 5 of 8
What does !! in the password field of /etc/shadow indicate?
!! in the shadow password field means no password has ever been set — the account was created but passwd was never run for it. The account cannot be used for password-based login. A single ! prefix on an existing hash (like !$6$...) means the account is administratively locked by usermod -L or passwd -l.Question 6 of 8
Which command creates a system account named webservice that cannot log in interactively and has no home directory?
useradd -r -M -s /sbin/nologin webservice: -r creates a system account (UID below 1000), -M suppresses home directory creation, -s /sbin/nologin sets a shell that prints a message and exits cleanly when anyone tries to log in. Option A creates a regular user account. Option C uses -L which is not a valid useradd flag (it's a usermod flag).Question 7 of 8
User carol's primary group is carol. She creates a file in a directory with SGID set and owned by group devs. What group owns the new file?
devs.Question 8 of 8
You see the line alice:x:1001:1001:Alice Smith:/home/alice:/bin/bash in /etc/passwd. What does the first 1001 represent?
/etc/passwd are: username : password : UID : GID : GECOS : home : shell. The third field (first 1001) is the UID. The fourth field (second 1001) is the primary GID. In this case they happen to match — alice's UID and private group GID are both 1001, which is typical when a user is created with a user private group (the default on RHEL).