Confirm system-wide useradd defaults, ensure prerequisite groups exist, provision a contractor account in a single ticket-style command, then verify identity, NSS records, and expiration settings using getent, id, and chage. Finish with clean lab hygiene by removing the user and home directory.
Ticket INC-150: Onboard a contractor account satoshi for a short change window. Requirements:
Confirm defaults first, create the account once with the full spec, verify, and then clean up the lab host.
useradd -D
before provisioning.
groupadd -f
to keep runs idempotent.
useradd
command using UID, primary group, supplementary groups,
comment, shell, home, expiry, and inactive settings.
getent passwd
provides the authoritative user record view for the system.
id
proves group membership by name (GIDs can vary).
chage -l
reports account expiry, password ageing fields, and derived dates.
useradd -D
Defaults matter because they silently apply to new accounts. This is where you confirm baseline HOME, SHELL, SKEL, and global INACTIVE/EXPIRE defaults before you override anything per-ticket.
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
sudo groupadd -f developers && sudo groupadd -f docker && sudo groupadd -f wheel
Using
-f
makes the command safe to rerun. If the group already
exists, groupadd exits successfully and the workflow stays
predictable.
sudo useradd -m -u 1055 -g developers -G wheel,docker -c 'Satoshi Nakamoto' -s /bin/bash -d /home/satoshi -e 2025-12-31 -f 30 satoshi
This is the ticket-style “do it once” provisioning command. It creates the home directory, pins the UID, sets primary and supplementary groups, writes the gecos comment, sets shell and home, enforces an account expiration date, and sets the inactivity lockout window.
getent passwd satoshi
getent
confirms the system’s authoritative user record view,
including UID, primary GID, home directory, and login shell.
GID numbers vary across systems, so focus on the group name
mapping.
satoshi:x:1055:1001:Satoshi Nakamoto:/home/satoshi:/bin/bash
(GID number may vary; primary group must be developers)
id satoshi
id
is the practical verification for access and privilege. The
ticket requirement is group names: developers as the primary
group, and wheel and docker as supplementary groups.
uid=1055(satoshi) gid=1001(developers) groups=1001(developers),10(wheel),993(docker)
(group IDs may vary; group NAMES must include developers, wheel, docker)
sudo chage -l satoshi
chage -l
confirms the account expiration date and displays password
aging fields. Note that password expiry fields can show
“never” on new accounts until a password policy is applied
and a password is set.
Last password change : Feb 01, 2026
Password expires : never
Password inactive : never
Account expires : Dec 31, 2025
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
sudo userdel -r satoshi
Removing the user and home directory keeps the lab host clean and repeatable. In a real environment, cleanup would also include access revocation and audit trail updates.
The ticket UID collides with an existing account. Verify the current UID allocation and either pick a new UID per policy or deconflict with the requester.
Create prerequisite groups first. If the group is managed by
directory services, ensure NSS is configured correctly and
the group is resolvable via
getent group developers
.
Ensure you used
-G wheel,docker
and verify group names match exactly. If you are modifying an
existing user, use
usermod -aG
to avoid overwriting groups.
The inactive window applies after password expiry. If the password is set to never expire, inactive will also be irrelevant. Confirm password policy and expiration settings if you need to test inactive lockouts realistically.
This lab is complete after verification and user removal. If you are repeating runs, confirm the user no longer exists and the home directory is gone.
getent passwd satoshi
ls -ld /home/satoshi
getent passwd satoshi
returns no output and
/home/satoshi
does not exist.
useradd -D
: Displays system-wide defaults for new accounts.
-D
: Show or set default values.
groupadd -f <group>
: Creates a group if it does not exist.
-f
: Exit successfully if the group already exists.
useradd -m -u <uid> -g <group> -G <g1,g2> -c '<comment>' -s <shell> -d <home> -e <YYYY-MM-DD> -f <days> <user>
: Creates a user with explicit ticket requirements.
-m
: Create the user’s home directory.
-u
: Set numeric UID.
-g
: Set primary group.
-G
: Set supplementary groups (comma-separated).
-c
: Set account comment (GECOS).
-s
: Set login shell.
-d
: Set home directory path.
-e
: Set account expiration date.
-f
: Set inactive days after password expiry.
getent passwd <user>
: Shows the NSS passwd entry for a user.
id <user>
: Displays UID, primary group, and supplementary groups.
chage -l <user>
: Shows password aging and account expiration details.
userdel -r <user>
: Removes the user and their home directory.
-r
: Remove home directory and mail spool.