LFCS Certification User and Group Management 2 — Questions and Answers
Question 1: Which file stores hashed passwords and password aging information for local user accounts on Linux?
- /etc/passwd
- /etc/shadow (Correct answer)
- /etc/group
- /etc/gshadow
Correct answer: /etc/shadow
/etc/shadow stores hashed passwords along with password aging fields such as last change date, min/max age, and expiry.
Question 2: A user needs to be added to the 'docker' group without logging out. Which command applies the new group membership to the current shell session?
- newgrp docker (Correct answer)
- usermod -aG docker $USER
- groupadd docker
- su - $USER
Correct answer: newgrp docker
newgrp docker starts a new shell with the specified group as the primary group, applying membership immediately without a full re-login.
Question 3: What is the effect of setting a user's shell to /sbin/nologin in /etc/passwd?
- The account is deleted
- The user cannot log in interactively (Correct answer)
- The user's password is disabled
- The account is locked after 3 failed attempts
Correct answer: The user cannot log in interactively
Setting the shell to /sbin/nologin prevents interactive login while still allowing the account to be used for services.
Question 4: Which command displays the numeric UID and GID, and all supplementary groups, for the currently logged-in user?
- whoami
- who
- id (Correct answer)
- groups
Correct answer: id
The id command prints the real UID, primary GID, and all supplementary group IDs and names for the current user.
Question 5: An administrator wants to force a user to change their password on next login. Which command accomplishes this?
- passwd --expire username
- usermod --must-change username
- chage -d 0 username (Correct answer)
- chage -M 0 username
Correct answer: chage -d 0 username
chage -d 0 sets the last password change date to the epoch, which forces the system to require a password change at next login.
Question 6: Which field in /etc/passwd defines the user's home directory?
- Field 4
- Field 5
- Field 6 (Correct answer)
- Field 7
Correct answer: Field 6
The sixth colon-delimited field (index 5, counting from 0) in /etc/passwd specifies the user's home directory path.
Question 7: What does the -r flag do when passed to the useradd command?
- Removes the user after creation
- Creates a system account with a UID below the normal range (Correct answer)
- Forces recursive home directory creation
- Resets the user's password on first login
Correct answer: Creates a system account with a UID below the normal range
useradd -r creates a system account, typically with a UID below 1000, no home directory by default, and no password aging.
Which file stores hashed passwords and password aging information for local user accounts on Linux?