LFCS Certification User and Group Management 4 — Questions and Answers
Question 1: Which command changes the primary group of an existing user to 'staff'?
- usermod -g staff username (Correct answer)
- usermod -G staff username
- groupmod -u username staff
- chgrp staff username
Correct answer: usermod -g staff username
usermod -g (lowercase) sets the primary group, while -G (uppercase) sets supplementary groups, so -g staff is correct for changing the primary group.
Question 2: A user 'alice' has UID 1005. After deleting her account with userdel, a new user 'bob' is created and happens to receive UID 1005. What risk does this create?
- Bob's password will be set to Alice's old password
- Bob will own files previously owned by Alice that were not reassigned (Correct answer)
- Bob will be added to all of Alice's groups automatically
- The system will refuse to create Bob's account due to UID conflict
Correct answer: Bob will own files previously owned by Alice that were not reassigned
Files on disk store the numeric UID, not the username, so any files Alice owned that weren't removed or reassigned will now appear owned by Bob.
Question 3: Which file must be edited to set a system-wide default umask for all users?
- /etc/profile (Correct answer)
- /etc/environment
- /etc/login.defs
- /etc/bashrc
Correct answer: /etc/profile
/etc/profile is sourced by login shells for all users and is the standard place to set a system-wide default umask.
Question 4: What does the GECOS field (field 5) in /etc/passwd typically store?
- The user's encrypted password
- The user's primary group ID
- Human-readable information like the user's full name and contact details (Correct answer)
- The path to the user's home directory
Correct answer: Human-readable information like the user's full name and contact details
The GECOS field stores optional descriptive information about the user, conventionally the full name, office, phone number, and other details, used by commands like finger.
Question 5: How do you add an existing user 'jane' to the supplementary group 'developers' without removing her from other groups?
- usermod -G developers jane
- usermod -aG developers jane (Correct answer)
- groupmod -a jane developers
- adduser jane developers
Correct answer: usermod -aG developers jane
The -a (append) flag combined with -G ensures jane is added to 'developers' without overwriting her existing supplementary group memberships.
Question 6: Which nsswitch.conf entry controls where the system looks up user account information?
- hosts
- passwd (Correct answer)
- group
- shadow
Correct answer: passwd
The 'passwd' entry in /etc/nsswitch.conf specifies the lookup order (e.g., files, ldap, sss) for user account information.
Question 7: A sysadmin wants to set account expiry for user 'tom' to December 31, 2026. Which command is correct?
- passwd --expire 2026-12-31 tom
- usermod -e 2026-12-31 tom
- chage --expiredate 2026-12-31 tom
- Both B and C are correct (Correct answer)
Correct answer: Both B and C are correct
Both usermod -e YYYY-MM-DD and chage -E YYYY-MM-DD (or --expiredate) can set account expiry; either command is valid for this task.
Which command changes the primary group of an existing user to 'staff'?