LFCS Certification User and Group Management 5 — Questions and Answers
Question 1: What is the difference between a user's login shell being /bin/false versus /sbin/nologin?
- /bin/false deletes the account; /sbin/nologin locks it
- /bin/false immediately exits silently; /sbin/nologin prints a message before exiting (Correct answer)
- /sbin/nologin disables the password; /bin/false disables the shell
- There is no functional difference for interactive login prevention
Correct answer: /bin/false immediately exits silently; /sbin/nologin prints a message before exiting
/sbin/nologin prints a configurable 'account is not available' message before exiting, while /bin/false exits immediately with no output.
Question 2: Which command displays the groups a specific user belongs to, showing both primary and supplementary groups?
- id -G username
- groups username (Correct answer)
- getent group | grep username
- Both A and B
Correct answer: groups username
groups username lists all groups (primary and supplementary) for the specified user; id also works but groups is more concise for this purpose.
Question 3: An admin creates a user with 'useradd -M username'. What does -M do?
- Creates the home directory and sets it as the mail directory
- Skips creating the user's home directory (Correct answer)
- Sets a mandatory password change on first login
- Creates the user with membership in multiple groups
Correct answer: Skips creating the user's home directory
useradd -M (uppercase) explicitly instructs useradd NOT to create the home directory, even if the CREATE_HOME default is set to yes in /etc/login.defs.
Question 4: Where would you configure the range of UIDs automatically assigned to new regular users created with useradd?
- /etc/passwd
- /etc/adduser.conf
- /etc/login.defs (Correct answer)
- /etc/security/limits.conf
Correct answer: /etc/login.defs
/etc/login.defs contains UID_MIN and UID_MAX parameters that define the range from which useradd selects UIDs for new regular users.
Question 5: A user reports they cannot run sudo. After verifying their account exists, what should you check first?
- Whether their home directory exists
- Whether they are a member of the sudo or wheel group (Correct answer)
- Whether their shell is /bin/bash
- Whether their UID is above 1000
Correct answer: Whether they are a member of the sudo or wheel group
sudo access is typically granted by membership in the 'sudo' group (Debian/Ubuntu) or 'wheel' group (RHEL/CentOS), so group membership is the first thing to verify.
Question 6: Which command would correctly lock a user account named 'contractor' by disabling password authentication without deleting the account?
- userdel -l contractor
- usermod -L contractor (Correct answer)
- passwd -e contractor
- chage -E 0 contractor
Correct answer: usermod -L contractor
usermod -L locks the account by prepending '!' to the password hash in /etc/shadow, preventing password-based login while keeping the account intact.
Question 7: What is the correct syntax to change the comment (GECOS) field for a user named 'alice' to 'Alice Johnson'?
- usermod -c 'Alice Johnson' alice
- chfn -f 'Alice Johnson' alice
- passwd -c 'Alice Johnson' alice
- Both A and B are correct (Correct answer)
Correct answer: Both A and B are correct
Both usermod -c and chfn -f can update the GECOS/comment field; usermod -c sets the full comment field, while chfn -f sets the full name portion.
What is the difference between a user's login shell being /bin/false versus /sbin/nologin?