A successful read as an administrator does not prove that a reader can open the same note. You need the intended reader's real process credentials and the complete path conditions. This lesson builds one small account relationship so you can observe a denial, grant one group membership, and observe a read as a fresh, separately checked reader.
Every command on this page runs inside the disposable Ubuntu guest. Stay
logged in as your ordinary course user. Only the individually labelled sudo
commands perform guest administration or launch a check as the named reader.
The course host is not the place for these account changes.
1. Separate setup authority from access evidence
There are three roles:
| Role | Purpose |
|---|---|
| Your ordinary course account | Run the lesson and retain its evidence; its groups remain unchanged. |
| Root for an authorized setup command | Create and configure only the named lab objects. |
vecta-lab-reader for a fresh command | Supply the actual unprivileged identity and read result. |
The reader has a separately created primary group, also called
vecta-lab-reader. A second new group, vecta-lab-group, controls access to
one shared note. These are different group objects with different recorded
numeric GIDs. Do not guess their IDs or assume either equals the new UID.
The shared directory is /var/tmp/vecta-lab-access, outside the ordinary
user's private home path. This is the course's explicit shared-fixture
exception to ~/linux-practice/. Root owns the directory and note; their
owning group is vecta-lab-group. The directory has mode 750, and the note
has mode 640. A reader without the access group cannot search that
directory. Once the appropriate group is present in a fresh reader process,
the directory's group search and the file's group read permit the read under
the checked ordinary access conditions.
The file still belongs to root. Giving it a group and changing a group membership are different operations; neither requires adding your course account to anything or changing authentication policy.
A new process supplies a new group check
Account database membership and a running process's credentials are related but distinct. A process normally keeps the groups with which it started; changing the database does not rewrite every existing session's group set.
sudo -u USER -- COMMAND asks the configured sudo policy to run that command
as USER. Here each invocation is a new short command. We will first run the
external id as the reader, inspect its actual credentials, and then launch
the read as the same selected identity. Do not use the group-preserving
sudo -P option or treat id USER's account lookup as a substitute for this
fresh process check. If sudo authorization fails, that is not a file-access
experiment.
2. Establish the scope, configuration and collision checks
Goal: create only the listed lab objects, prove the reader's denied and allowed reads, complete the independent variation, then remove only the created objects. You need the previously verified Ubuntu guest, an ordinary nonzero UID and authorization for the bounded guest administration below. No root shell, login as the reader, password change, learner membership change, sudoers edit or profile change is part of this exercise.
Run one line at a time and inspect each result before continuing. Stop after an unexpected error; never continue a multi-step mutation sequence merely because later lines are visible.
id -u
id -un
id
ps -p $ -o comm=
type -a cd pwd sudo id getent ps printf set mkdir ls cp cat stat chmod chown chgrp rm rmdir adduser addgroup usermod deluser delgroup
Require your expected nonzero guest identity, Bash and known command origins.
Record your current numeric group set. The known Bash cd, pwd, printf and set
builtins are expected; ordinary utilities must be the distribution's
executables. An understood color-only ls alias may be retained, because
privileged calls below use inspected executable paths.
The taught type -P identifies the external executable in PATH. Inspect the
following before using their absolute forms through sudo:
type -P sudo id getent mkdir ls cp cat stat chmod chown chgrp rm rmdir adduser addgroup usermod deluser delgroup
The commands below use /usr/bin/ for sudo and the listed file/identity
utilities, and /usr/sbin/ for the account tools. Require those expected
paths; reconcile an unexpected location or shadowing rather than blindly
running a different privileged program. An absolute command argument also
makes clear which executable sudo is asked to launch.
Inspect installed version/help evidence with the normal account:
/usr/sbin/adduser --version
/usr/sbin/deluser --version
/usr/bin/chgrp --version
/usr/bin/sudo --version
/usr/sbin/usermod --help
This course targets Ubuntu Noble's adduser/deluser 3.137 family, GNU Coreutils
9.4 and traditional sudo 1.9. The usermod help must support the documented
-a/-G combination. Unexpected versions, failed help/plugin initialization
or missing tools are readiness gaps to reconcile before account creation.
Do not install replacements as a side effect of this lesson.
Require read-only set -o to show errexit off for the deliberately missing
lookups and denied reads. Preserve a different setting and reconcile it.
set -o
Read the account helpers' policy before they can change anything
The helper tools read configuration; their defaults are not permission to ignore local overrides. Inspect these files as text, using the earlier configuration/help reading skills:
cat /etc/adduser.conf
cat /etc/deluser.conf
cat /etc/login.defs
cat /etc/default/useradd
ls -ld /usr/local/sbin/adduser.local /usr/local/sbin/deluser.local
A # at the start of a configuration line marks a comment, not an active
setting. Read commented examples together with the installed documentation's
defaults; do not execute configuration text as shell commands.
| Policy to establish before proceeding | Accepted scope |
|---|---|
| Extra group additions | No custom or privileged additions. ADD_EXTRA_GROUPS is disabled; a documented ordinary USERS_GROUP such as users may still contribute a baseline group. Record the actual result. |
| Fixed identity pools and quota copying | No active UID_POOL, GID_POOL or QUOTAUSER, and no unexplained custom creation behavior. |
| Home creation | This lesson explicitly uses --no-create-home; the passwd entry has a home field, but no physical home is created by this route. |
| Removal and backup behavior | REMOVE_HOME, REMOVE_ALL_FILES and BACKUP are off; account deletion must not sweep files or create a backup. |
| Lower-level removal command | USERDEL_CMD in login.defs is inactive; no custom cleanup command is invoked. |
| Mail location and creation | Establish MAIL_DIR as the recorded canonical mail directory, with no alternative MAIL_FILE; record the CREATE_MAIL_SPOOL policy without assuming its outcome. Inspect actual paths after creation. |
| Local hooks and custom account behavior | The two named local hook paths are absent; the lower-level hook tree is absent or contains only ordinary empty directories, as checked below. |
The underlying account tools can run hooks under /etc/shadow-maint.
Inspect that one path before any account creation:
ls -ld /etc/shadow-maint
An understood missing-path result means the tree is absent. If it exists,
require the expected ordinary directory, not a link, before the next read.
For this read-only check, GNU ls -R lists the contents of subdirectories
recursively; combined -laR adds the taught long metadata and hidden entries.
It changes nothing and is not a recursive removal command.
ls -laR -- /etc/shadow-maint
Run this second line only for the existing checked tree. Require no hook files, links or other executable entries: it may contain only ordinary empty hook directories. Read every listed directory, including hidden entries. A file, unreadable section or unexplained object blocks this procedure; do not delete or disable hooks. The tools' configured helper behavior is part of the boundary, not something a later cleanup command can safely guess.
If a file is unreadable, an effective setting is uncertain, a hook exists, or the configuration would broaden the actions, stop before account mutation. Do not change global configuration to fit the example. Review these same conditions again before cleanup if the session was interrupted or configuration could have changed.
Check names in both the account and group databases
getent passwd NAME queries the named account through the configured Name
Service Switch. A returned passwd record has colon-separated fields for
name, password placeholder, numeric UID, numeric primary GID, comment, home
and shell. It is a named account lookup, not the credentials of a new process.
getent group NAME queries the group record as in the identity lesson.
For each new name, require no record and the documented not-found status 2.
Use $? immediately after each lookup; permission or service errors are not
proof that a path or identity is safe to create.
getent passwd vecta-lab-reader
printf 'Reader lookup status: %s\n' "$?"
getent group vecta-lab-reader
printf 'Primary-group lookup status: %s\n' "$?"
getent group vecta-lab-group
printf 'Access-group lookup status: %s\n' "$?"
Stop at any existing record or unexplained result. A lab-looking name does
not make a preexisting account or group yours. Also confirm the named root
account resolves to UID 0; this is the owner selected later, not a guessed
new lab UID:
getent passwd root
Check file paths, including places the helpers may use
Inspect known parents and both possible spellings of the mail location:
ls -ld / /var /var/tmp /home /var/mail /var/spool/mail
ls -ld ~ ~/linux-practice
The shared path's traversed parents must be the known guest directories with
search permission for the intended reader. /var/tmp commonly has its normal
sticky-directory mode; leave that system parent unchanged. No extra access
controls on the new fixture are permitted. A documented /var/spool/mail
link to /var/mail is a parent alias, not a second mailbox to remove. Establish
and record /var/mail as the canonical mail directory for the commands below;
stop and reconcile a different layout.
Use the ordinary sudo authorization to inspect protected final paths if
needed. sudo without -u selects root under the standard course policy;
-- ends its options before the exact executable. This first command checks
that selected identity only:
sudo -- /usr/bin/id -u
Require 0 for that command, while your surrounding shell remains the normal
user. This is not a root-shell instruction. Now require the following final
paths to be absent, with understood missing-path diagnostics rather than
permission failures:
sudo -- /usr/bin/ls -ld /home/vecta-lab-reader
sudo -- /usr/bin/ls -ld /var/mail/vecta-lab-reader
sudo -- /usr/bin/ls -ld /var/spool/mail/vecta-lab-reader
sudo -- /usr/bin/ls -ld /var/tmp/vecta-lab-access
ls -ld ~/linux-practice/manage-lab-identities
Stop before creation if any exists. Record these absent paths, the absent account/groups and the date with your evidence. This record establishes which objects the following successful creation commands can legitimately own.
3. Prepare the synthetic input and create the two groups
Create only the absent local exercise directory, then inspect its identity:
mkdir ~/linux-practice/manage-lab-identities
ls -ld ~/linux-practice/manage-lab-identities
Require the new ordinary owned directory without links or extra access indicators. Enter it and verify location before creating the note:
cd ~/linux-practice/manage-lab-identities
pwd
ls -a
Record the exact local exercise path. Continue only when the path matches
and the inventory contains only . and ...
printf '%s\n' 'Access follows the checked reader.' 'Keep this note unchanged.' > note.txt
ls -ld note.txt
cat note.txt
Require a regular single-link file owned by your course UID. Its exact two newline-terminated lines are:
Access follows the checked reader.
Keep this note unchanged.
Guest administration begins with two explicit group creations. addgroup GROUP creates the named local group and chooses an available numeric GID.
It does not add your learner account to that group. Create each only after
its earlier absent-name check, and inspect before the next creation:
sudo -- /usr/sbin/addgroup vecta-lab-reader
getent group vecta-lab-reader
Record the new primary group's numeric GID and empty explicit member field. Then create the separate access group:
sudo -- /usr/sbin/addgroup vecta-lab-group
getent group vecta-lab-group
Record its different numeric GID and empty member field. If a creation fails or an ID/record differs unexpectedly, stop and record partial progress. Do not claim an object was created just because it now exists.
4. Create a reader without a physical home
The complete adduser invocation below has these explicit choices:
| Argument | Meaning |
|---|---|
--disabled-password | Skip setting a password. It does not disable every possible authentication method. |
--comment 'Course lab reader' | Supply the synthetic account comment, avoiding an interactive personal-details dialogue. |
--ingroup vecta-lab-reader | Use the already created primary group; do not rely on automatic same-name group creation. |
--home /home/vecta-lab-reader | Set that absolute home field in the account record. |
--no-create-home | Leave the physical home absent; this lesson needs no login shell, skeleton files or home cleanup. |
--shell /bin/bash | Set the known guest Bash path as the account's shell field. |
Final vecta-lab-reader | The new account name. |
This does not authorize an SSH key, reader login, authentication change or additional group. Execute the single scoped account creation:
sudo -- /usr/sbin/adduser --disabled-password --comment 'Course lab reader' --ingroup vecta-lab-reader --home /home/vecta-lab-reader --no-create-home --shell /bin/bash vecta-lab-reader
getent passwd vecta-lab-reader
getent group vecta-lab-reader
Require the new nonzero UID, the recorded private primary GID, the exact comment/home/shell fields and the same recorded group object. Save the UID and both group GIDs outside the disposable note. Do not infer membership from the private group's comma-separated member field; primary membership need not appear there.
Inspect the physical home and mail paths again:
sudo -- /usr/bin/ls -ld /home/vecta-lab-reader
sudo -- /usr/bin/ls -ld /var/mail/vecta-lab-reader
The home must remain absent under the explicit option. An unexpected home is a setup discrepancy; do not recursively remove it. A mail spool may depend on the installed account tools and configuration. If none was created, record continued absence. If a spool appeared, inspect that one canonical path:
sudo -- /usr/bin/stat -c 'path=%n type=%F uid=%u gid=%g links=%h bytes=%s' -- /var/mail/vecta-lab-reader
Run that inspection only when the path exists. %s adds the file's byte size
to the previously taught stat fields. Record its actual owner, group, type,
link count and size. The bounded optional cleanup later applies only to a
newly introduced ordinary reader-owned, single-link empty spool. A link,
unknown owner, nonempty mailbox or unexplained side effect must be retained
and diagnosed; do not sweep it away or continue as if the starting state matched.
Verify actual fresh-reader credentials before a read
Now teach the target-user option in practice: -u vecta-lab-reader selects
that account for just this command; -- separates sudo options from the
absolute external executable. The reader does not need a password for this
authorized invocation; sudo authorization belongs to your course account.
sudo -u vecta-lab-reader -- /usr/bin/id
Require the recorded nonzero reader UID and recorded private primary GID.
Record the whole initial numeric group set. The ordinary Ubuntu baseline
may also supply a documented users group; do not assume only one group.
The access group must be absent, and every other group must be understood
and nonprivileged. Unexpected administrative or custom memberships are a stop
condition, not something to remove blindly. Your normal shell still has its
original identity and groups.
5. Configure the shared note as root, then test as the reader
The shared final path was absent. mkdir creates only that directory. Set
its explicit private-to-the-lab mode before copying the note:
sudo -- /usr/bin/mkdir /var/tmp/vecta-lab-access
sudo -- /usr/bin/ls -ld /var/tmp/vecta-lab-access
Require a new root-owned ordinary directory with no link/ACL/context/unknown
access indicator or special bits. chmod 750 gives root rwx, owning group
r-x, other nothing. Apply it to this one directory:
sudo -- /usr/bin/chmod -- 750 /var/tmp/vecta-lab-access
From the verified local exercise directory, recheck the local note's identity and text. The destination inside the new shared directory must be absent.
pwd
ls -ld note.txt
cat note.txt
sudo -- /usr/bin/ls -ld /var/tmp/vecta-lab-access/note.txt
Only after those checks, use the taught exact-file copy: -i asks before an
overwrite and -T prevents treating the target as a directory. Any overwrite
prompt means the expected absence changed: decline using the understood
response convention and stop, rather than replacing an existing object.
sudo -- /usr/bin/cp -iT -- note.txt /var/tmp/vecta-lab-access/note.txt
Require a newly created ordinary single-link note. Inspect it before changing its ownership or mode:
sudo -- /usr/bin/ls -ld /var/tmp/vecta-lab-access/note.txt
chown OWNER PATH changes the owning user to the named, already verified
account. Here root resolves to UID 0; no guessed lab numeric ID or colon
shorthand is used. chgrp GROUP PATH changes the owning group separately.
Both commands below name exactly the two newly created objects, with no
recursive option. chmod 640 then gives root read/write, group read, other
nothing, and no file execute bit.
sudo -- /usr/bin/chown -- root /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/chgrp -- vecta-lab-group /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/chmod -- 640 /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/stat -c 'path=%n mode=%a (%A) uid=%u gid=%g links=%h' -- /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/cat /var/tmp/vecta-lab-access/note.txt
Require root UID 0, the recorded access-group GID, directory 750, file
640, the note's single link, ordinary access indicators, and both exact
text lines. Record this complete controlled fixture state. A root read verifies
the copied input; it is not evidence of reader access.
Predict and observe the first reader denial
The fresh reader does not own either object and lacks the access group. The directory therefore selects its other-class rights, which provide no search permission. The file's group-read bit cannot bypass this earlier path component. The absolute lookup also requires search on its other traversed directories, already inspected above.
First recheck fresh credentials, then make a separate fresh read attempt:
sudo -u vecta-lab-reader -- /usr/bin/id
Require the recorded initial group set and access-group absence. Only then:
sudo -u vecta-lab-reader -- /usr/bin/cat /var/tmp/vecta-lab-access/note.txt
printf 'Reader read status: %s\n' "$?"
Expect a file permission-denied diagnostic, nonzero status and no note text. The immediate status is the preceding sudo invocation's result; distinguish a successful launch followed by the file denial from a sudo authentication or policy failure. A root read or an unexpected successful reader read does not satisfy this stage: stop and inspect identity, parent search, group/mode and other access controls before changing membership.
6. Append one membership and launch a fresh reader
usermod -G GROUP USER sets a user's supplementary group list. The additional
-a means append, retaining existing supplementary groups. Omitting it
can replace unrelated memberships. The combined -aG form below changes
only the named synthetic reader's relationship with the new access group.
It does not alter your learner account or the reader's primary group.
sudo -- /usr/sbin/usermod -aG vecta-lab-group vecta-lab-reader
getent group vecta-lab-group
The group record should now list the reader as an explicit member. That is database evidence. Next obtain fresh process evidence:
sudo -u vecta-lab-reader -- /usr/bin/id
Require the same reader UID and primary GID, all recorded initial groups still present, and the access group newly present. Do not rely on a terminal that was already running as the reader. If the fresh credentials differ, stop before claiming the membership result or trying to broaden access.
sudo -u vecta-lab-reader -- /usr/bin/cat /var/tmp/vecta-lab-access/note.txt
printf 'Reader read status: %s\n' "$?"
Require status 0 and exactly the two original lines. Recheck the fixture's
mode/group and your unchanged normal id as well. Only membership changed
between the controlled denied and allowed stages; the directory stayed 750
and the file 640. That comparison is stronger evidence than an administrator
opening a file successfully.

The figure is an expected access model to compare with your own identity, metadata, status and content observations. Read the blue task-order arrows and privileged setup areas separately from the green fresh-reader path checks. The dashed note in the first check is unchanged but unreached because directory search stops earlier. The second check uses newly inspected credentials, not a privilege upgrade of the earlier process. All other traversed-path and ordinary-access conditions remain part of the experiment.
Diagnose the failing layer
| Observation | Check before any repair |
|---|---|
| A named user, group or path exists before setup. | Preserve it; names do not establish ownership. |
| Creation produces an unexpected group, home or mailbox. | Compare configuration and the recorded actual outputs; stop before broad cleanup. |
| Root can read but the reader cannot. | Check the reader's actual UID/groups, then directory search and file read separately. |
| Group record changed but a previous session still fails. | A database change does not update every existing process; launch and inspect fresh credentials. |
| Fresh reader unexpectedly has administrative groups. | The intended nonprivileged baseline has not been established; do not perform the access experiment. |
| Correct file group but denied path. | Inspect each traversed directory and other access controls, not just the final file. |
| Sudo refuses a command. | Resolve authorization/readiness; that is not the intended file denial. |
Independent task: change one file permission, then restore it
Start from the verified allowed-reader state: same UID and fresh groups,
directory 750, note 640, root ownership, access-group GID and exact text.
Write a prediction before doing anything: if you remove only the note's
group-read bit, where should the reader now be stopped? What should remain
unchanged about directory traversal and membership?
The previous permission lesson taught symbolic single-bit changes. Here g
selects the group class: g-r removes group read and g+r restores it. The
known starting note has that read bit, so its exact recovery is already
understood. Work only on this root-owned shared note through one explicitly
selected guest sudo command; do not change the directory, owner or groups.
Apply the single-bit condition, inspect the resulting full mode, launch a
fresh reader id, and attempt the read as that reader. Then restore the one
bit and repeat the complete identity/mode/content check. Keep the diagnosis
separate from the earlier failure at directory search.
Success: the changed-file test and restored-file test agree with your prediction, the recorded identity/group/directory state remains unchanged, and the restored read returns the exact two lines. Explain why the new sudo invocation matters even though a group database lookup already showed the reader's membership. Attempt this before opening the hints.
Hint 1
An allowed directory traversal does not imply the selected file class can read the file. Identify which object's bit you changed.
Hint 2
Use the already recorded reader UID and access-group membership. Keep the
fresh id check separate from the file read, and inspect the immediate status.
Hint 3
The controlled change is chmod -- g-r on the shared note; its bounded
inverse is chmod -- g+r on that same note. The target was known to have the
bit before removal. Nothing about this task requires another group or user.
Answer and Reasoning
After rechecking the unchanged fixture identity and starting file mode, one solution applies the new condition:
sudo -- /usr/bin/chmod -- g-r /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/stat -c 'path=%n mode=%a (%A) uid=%u gid=%g links=%h' -- /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -u vecta-lab-reader -- /usr/bin/id
Require the directory still 750, the file now 600, unchanged root owner
and access-group GID, and the same reader's complete post-membership group
set. The reader can traverse the directory but its selected group class on
the file has no read bit. Only after verifying that identity:
sudo -u vecta-lab-reader -- /usr/bin/cat /var/tmp/vecta-lab-access/note.txt
printf 'Independent read status: %s\n' "$?"
Expect nonzero status and a file permission denial, with no note text. This time the missing permission belongs to the file; the earlier denial occurred while resolving its parent directory.
Restore the one bit proven present in the starting state:
sudo -- /usr/bin/chmod -- g+r /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/stat -c 'path=%n mode=%a (%A) uid=%u gid=%g links=%h' -- /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -u vecta-lab-reader -- /usr/bin/id
Require the complete recorded 750/640 state and unchanged fresh reader
credentials before the final read:
sudo -u vecta-lab-reader -- /usr/bin/cat /var/tmp/vecta-lab-access/note.txt
printf 'Restored read status: %s\n' "$?"
Require status 0 and both original lines. Fresh process credentials are the
actual check of membership used by this command; the group database alone
does not prove the credentials of a previously started process.
Cleanup: remove only the recorded new objects
Finish and verify the independent restoration first. Keep the creation record until every deletion is checked. All short reader commands must have returned; this lesson started no reader login, background program or other workload. If an account tool reports that the user is still in use, stop and investigate rather than killing an unknown process or forcing deletion.
Review the configuration/hook scope again if anything could have changed.
The cleanup below uses account-only deletion, no --remove-home, no
--remove-all-files, no recursion and no blanket ownership repair.
Remove the shared fixture while its identity is still resolvable
Inspect known parents, the exact shared directory and note. Use ls -a on
the directory to include hidden entries:
sudo -- /usr/bin/ls -ld /var/tmp /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
sudo -- /usr/bin/ls -a /var/tmp/vecta-lab-access
sudo -- /usr/bin/stat -c 'path=%n mode=%a (%A) uid=%u gid=%g links=%h' -- /var/tmp/vecta-lab-access /var/tmp/vecta-lab-access/note.txt
Require the same recorded ordinary root-owned objects, access-group GID,
restored modes and only the known note. Establish the programs' documented
confirmation responses before any interactive copy/removal; shown y/n
assume English confirmations. Stop before a prompt when the convention is
unclear. Then remove that one note:
sudo -- /usr/bin/rm -i -- /var/tmp/vecta-lab-access/note.txt
Approve only the exact disposable path. A decline stops cleanup with the
remaining resources recorded. One n would not cancel later prompts in a
multi-target invocation; this command intentionally has one target.
sudo -- /usr/bin/ls -a /var/tmp/vecta-lab-access
Require only . and .. before empty-directory removal:
sudo -- /usr/bin/rmdir -- /var/tmp/vecta-lab-access
sudo -- /usr/bin/ls -ld /var/tmp/vecta-lab-access
Require the named final path absent. Keep /var/tmp itself unchanged.
Handle a recorded mailbox only if one was actually created
If the canonical mail path stayed absent, inspect it once more and skip
removal. If a spool was recorded as newly introduced, recheck exactly
/var/mail/vecta-lab-reader: it must remain ordinary, single-link, owned by
the recorded new UID and zero bytes. Do not rely on its name or on its owner
resolving after the account is gone.
sudo -- /usr/bin/ls -ld /var/mail/vecta-lab-reader
If the path is absent, record that result and skip both stat and removal. Only if the previously recorded spool still exists as the expected ordinary file, inspect its numeric ownership, link count and size:
sudo -- /usr/bin/stat -c 'path=%n type=%F uid=%u gid=%g links=%h bytes=%s' -- /var/mail/vecta-lab-reader
A nonempty or changed object stays in place and blocks this cleanup branch until diagnosed. Only a matching empty, newly created spool permits the optional single-file removal:
sudo -- /usr/bin/rm -i -- /var/mail/vecta-lab-reader
Use the understood response convention and verify absence afterward. If you decline, leave the spool in place and stop account/group cleanup as well; do not delete the account while leaving this unresolved recorded object. Never delete both mail alias paths or their parent directory.
Delete the account entry, then any remaining created groups
Reinspect the named account and both group records. Require their numeric IDs to match the creation record exactly; require the physical home still absent:
getent passwd vecta-lab-reader
getent group vecta-lab-reader
getent group vecta-lab-group
sudo -- /usr/bin/ls -ld /home/vecta-lab-reader
deluser USER under the reviewed account-only configuration removes that
named account record and its membership references. It does not authorize a
filesystem sweep. No physical home was created, so no home removal is needed.
sudo -- /usr/sbin/deluser vecta-lab-reader
getent passwd vecta-lab-reader
printf 'Deleted-reader lookup status: %s\n' "$?"
Require no record and status 2. The same-name primary group may already
have been removed by the account tools' policy. Inspect rather than guessing:
getent group vecta-lab-reader
printf 'Primary-group post-delete status: %s\n' "$?"
getent group vecta-lab-group
printf 'Access-group post-delete status: %s\n' "$?"
For each group, an absent result with status 2 needs no deletion. A surviving
group must have the same recorded GID and no unexpected members. The
delgroup --only-if-empty GROUP guard refuses a nonempty group; a group still
used as an account's primary group is not removable by this route. Run the
following line only for its corresponding surviving, verified empty group:
sudo -- /usr/sbin/delgroup --only-if-empty vecta-lab-reader
sudo -- /usr/sbin/delgroup --only-if-empty vecta-lab-group
Inspect each removal result before considering the next line. A refusal is
evidence to investigate, not permission to drop the guard. Verify both group
names now return no record/status 2. Recheck that the home, canonical mail
path and shared fixture are absent. No preexisting group is included.
Remove the ordinary local input last
Return to the normal-account local fixture only after the administrative objects have been reconciled. Inspect its parents and entry:
ls -ld ~/linux-practice ~/linux-practice/manage-lab-identities
Require the recorded ordinary owned directories. Then change location and verify the exact saved local path before deleting anything:
cd ~/linux-practice/manage-lab-identities
pwd
After that location agrees, inspect ls -a and ls -ld note.txt. Require
only the original ordinary owned single-link local note. Use the taught
one-target removal and understand its prompt:
rm -i -- note.txt
If declining, retain the local file and stop filesystem cleanup. Otherwise
verify ls -a shows only . and .., then return to the shared practice root:
cd ~/linux-practice
pwd
Require the known shared-root location before inspecting and removing the same empty exercise entry:
ls -ld manage-lab-identities
rmdir -- manage-lab-identities
id
Keep the shared practice root and all other lessons. Your final normal UID and numeric group set must match the initial record. The lab added and removed only its reader and two groups; it did not change learner membership or policy.
Resume by reconciling the creation record
An existing lab object is not automatically a collision to delete or a cue to rerun account creation. Compare each account/group's numeric ID, local and shared path identity, mode, mailbox state and actual reader membership with the saved record of successful steps. Check current configuration before another helper call. Reuse only objects whose creation and identity you can establish; preserve anything unexplained.
If the independent file-bit test was interrupted, restore g+r only on the
verified shared note whose recorded 640 starting state proves that bit was
present. Inspect the whole restored fixture and fresh reader before continuing.
If the user is already gone, do not recreate it to make cleanup familiar;
compare surviving group IDs and file numeric owners with the original record
and complete only the justified remaining cleanup steps.
Missing records, changed IDs, unexpected files or an in-use account require diagnosis. Do not force removal, clear memberships on an unrelated identity, recursively remove a home, or turn a sudo failure into a broader repair.
Sources and other study views
- S18 — Bash: argument handling and immediate status inspection
- S19 — GNU Coreutils: file copies, ownership, modes and bounded removal
- S24 — Ubuntu user and group administration
- S32 — Noble getent: named account/group queries
- S43 — Noble adduser/addgroup
- S44 — Noble deluser/delgroup
- S45 — Noble usermod: supplementary group changes
- S46 — Noble sudo: selected command identity
- S56 — Detailed adduser 3.134 companion
- S57 — Detailed sudo 1.9 companion
- S69 — Linux pathname lookup and ordinary access checks
- S70 — Noble adduser configuration
- S71 — Noble deluser configuration
- S72 — Shadow 4.13 userdel companion: removal policy, mail and hooks
Noble is the selected guest baseline. The older Debian companion manuals and newer upstream Coreutils/pathname documentation support bounded syntax and concepts; they do not establish your installed defaults. The configuration, identity, content and cleanup observations above are part of performing the lesson in that actual guest.
Revision reconstructs the identity experiment; Quick Reference retrieves its critical commands and guards.