🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Cybersecurity › Linux for Cybersecurity › Lesson 4
TEC-CYBE44-04 · Lesson 4 · 14.5 clock hours · lab

User and Group Management

Objective. Students create, modify, lock, and delete Linux user accounts and groups using standard command-line tools to support access-control policies.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Why User and Group Management Matters

Every Linux system enforces access control through user accounts and groups. In a cybersecurity role you will create accounts for new staff, restrict or remove access when people leave, and audit existing accounts for misconfigurations. The principle of least privilege — giving each account only the access it needs — is a core concept tested on the ISC2 CC, CompTIA Security+, and CompTIA CySA+ exams and enforced in CIS Benchmarks.

Key Files: /etc/passwd, /etc/shadow, and /etc/group

/etc/passwd stores one line per account. Each line has seven colon-separated fields: username, a placeholder `x` (password hash moved to shadow), UID, GID, GECOS comment, home directory, and login shell. Root always has UID 0. Any account with UID 0 that is not root is a critical vulnerability.

/etc/shadow stores the actual password hash along with aging fields: last change date, minimum days, maximum days, warning days, inactivity days, and expiry date. Only root (or processes with the `shadow` group) can read this file. A blank or `!` hash entry signals a locked or passwordless account — the latter is a serious weakness.

/etc/group lists group names, a placeholder, GID, and member usernames. The `sudo` group (or `wheel` on some distributions) grants administrative privilege. Membership should be audited regularly.

Creating Accounts: useradd

The `useradd` command creates a new account. Common options:

Example: `sudo useradd -m -s /bin/bash -G developers -c "Alex Rivera" arivera`

After creating the account, set a password immediately: `sudo passwd arivera`. Leaving a password unset is a security risk — the CIS Ubuntu Linux Benchmark recommends that all interactive accounts have a password or be explicitly locked.

Modifying Accounts: usermod

`usermod` changes an existing account. Key options:

When revoking sudo access, remove the account from the sudo group: `sudo gdeluser username sudo` or `sudo usermod -G "" username` after confirming other group memberships.

Password Aging: chage

`chage` manages the password aging fields in /etc/shadow.

The CIS Ubuntu Linux Benchmark provides specific recommended values for maximum password age and warning periods. Always reference the current benchmark version for your distribution.

Offboarding Safely

When an employee leaves, follow a consistent runbook to avoid data loss and unauthorized access:

1. Lock the account — `sudo usermod -L username` prevents login immediately.

2. Expire the password — `sudo chage -E 0 username` sets the expiry to the epoch, blocking any re-enable without admin action.

3. Revoke sudo — remove the account from the sudo/wheel group.

4. Archive the home directory — `sudo tar -czf /archive/username-$(date +%F).tar.gz /home/username` preserves files for HR or legal review before deletion.

5. Delete the account — `sudo userdel -r username` removes the account and its home directory. Use `-r` only after confirming the archive is complete.

Document every command in your runbook. In regulated environments, an incomplete offboarding record is itself a finding.

Group Management: groupadd and gpasswd

`groupadd rolename` creates a new group. `gpasswd -a username groupname` adds a member; `gpasswd -d username groupname` removes one. Groups enforce role-based access control (RBAC) — a concept central to all three target credentials.

Auditing for Weaknesses

Common misconfigurations to look for:

When you find a weakness, document it, apply the fix, and verify with the same command that revealed it.

Safety Notes

Always work in a dedicated lab VM — never practice account deletion or shadow file edits on a production system. Take a snapshot before the lab. Running commands as root carries risk; use `sudo` and verify each command before pressing Enter. Keep a copy of /etc/passwd and /etc/shadow before intentionally introducing weaknesses so you can restore them. Treat any exported shadow file as sensitive and delete lab copies securely when finished.

Key terms10

Principle of Least PrivilegeThe security practice of granting each account or process only the minimum access rights needed to perform its function, reducing the potential damage from errors or attacks.
UID (User Identifier)A numeric value the Linux kernel uses to identify a user account; UID 0 is reserved for root and grants full system privileges.
Password AgingPolicies stored in /etc/shadow that control how long a password is valid, how soon it can be changed, and when the account expires, managed with the chage command.
Shadow File (/etc/shadow)A root-readable file that stores hashed passwords and aging metadata separately from /etc/passwd to limit exposure of credential data.
Role-Based Access Control (RBAC)An access-control model in which permissions are assigned to roles (groups) rather than individuals, and users gain access by being added to the appropriate role.
Account LockingThe act of prepending an exclamation mark to the password hash in /etc/shadow (via usermod -L or passwd -l), preventing login without deleting the account or its files.
GECOS FieldThe comment field in /etc/passwd, typically used to store the user's full name or other descriptive information; has no effect on system authentication.
Supplementary GroupA group a user belongs to in addition to their primary group, granting access to resources owned by that group; managed with usermod -aG or gpasswd -a.
RunbookA documented, step-by-step record of the commands and decisions made during a repeatable operational procedure, such as offboarding a user, used for accountability and repeatability.
CIS BenchmarkA set of consensus-based configuration guidelines published by the Center for Internet Security that provide specific, auditable recommendations for hardening operating systems and software.
In class: Simulate an onboarding scenario: receive a list of five fictional employees with defined roles; create accounts with useradd, assign to appropriate groups with usermod, set password policies with chage, and produce a written access-control record for each account. · Simulate an offboarding scenario for two of those accounts: lock the accounts, expire passwords, revoke sudo access, archive the home directory, then delete accounts — capturing each command in a written runbook. · Inspect /etc/passwd, /etc/shadow, and /etc/group to identify three intentionally introduced security weaknesses (e.g., UID 0 duplicate, blank password hash) and document remediation steps.
Materials: Linux VM, man pages (useradd, usermod, userdel, chage, passwd), CIS Ubuntu Linux Benchmark (Center for Internet Security), ISC2 CC domain notes on access control
Check: Instructor audits /etc/passwd and /etc/group after each scenario; pass = all accounts match the specified policy with no extraneous privileges, and the runbook is complete and accurate.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Security+ — Threats, Vulnerabilities, and Mitigations
1. A security analyst runs `awk -F: '($3=="0"){print $1}' /etc/passwd` and sees two entries: `root` and `backup`. What is the correct remediation?
ISC2 CC — Access Controls Concepts
2. Which command locks a Linux user account without deleting it or its home directory?
CySA+ — Identity and Access Management
3. During an audit of /etc/shadow, you find an account whose second field (password hash) is empty. What does this indicate?
Security+ — Identity and Access Management
4. An analyst needs to force a newly onboarded user to change their temporary password on first login. Which command accomplishes this?
ISC2 CC — Access Controls Concepts
5. What is the purpose of using `usermod -aG developers arivera` rather than `usermod -G developers arivera`?
ISC2 CC — Access Controls Concepts
6. Which of the following best describes role-based access control (RBAC) as implemented through Linux groups?
CySA+ — Security Operations
7. During offboarding, an administrator runs `sudo userdel -r jsmith` before archiving the home directory. What is the likely consequence?
CySA+ — Security Operations
8. A CySA+ candidate is reviewing the CIS Ubuntu Linux Benchmark during a system hardening project. Which of the following best describes the benchmark's role in user management?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.