Linux User Management 5 — Questions and Answers
Question 1: What is the effect of setting a user's shell to `/sbin/nologin`?
- Deletes the user account on logout
- Prevents the user from getting an interactive login shell (Correct answer)
- Gives the user limited sudo access only
- Restricts the user to the /sbin directory
Correct answer: Prevents the user from getting an interactive login shell
/sbin/nologin is a placeholder shell that prints a message and exits, preventing interactive logins while allowing other service authentications.
Question 2: Which command shows the password aging information for a user named 'carol'?
- passwd -l carol
- chage -l carol (Correct answer)
- usermod --show carol
- id -a carol
Correct answer: chage -l carol
chage -l displays password aging details including last change, expiry, and warning dates for the specified user.
Question 3: When using `visudo`, what is the correct syntax to allow user 'dave' to run all commands as root without a password?
- dave ALL=(ALL) ALL
- dave ALL=(ALL) NOPASSWD: ALL (Correct answer)
- dave ALL=NOPASSWD ALL
- ALL dave=(root) NOPASSWD
Correct answer: dave ALL=(ALL) NOPASSWD: ALL
The NOPASSWD: keyword in the sudoers rule skips password prompting for the specified commands.
Question 4: What does the `pwck` command do?
- Changes a user's password
- Verifies the integrity of /etc/passwd and /etc/shadow files (Correct answer)
- Checks password strength
- Lists all users with weak passwords
Correct answer: Verifies the integrity of /etc/passwd and /etc/shadow files
pwck validates /etc/passwd and /etc/shadow for consistency, detecting duplicate UIDs, missing home directories, and format errors.
Question 5: Which command would delete the group 'contractors' from the system?
- userdel -g contractors
- rmgroup contractors
- groupdel contractors (Correct answer)
- groupmod -d contractors
Correct answer: groupdel contractors
groupdel removes the specified group from /etc/group and /etc/gshadow.
Question 6: What is the minimum number of days between password changes controlled by in /etc/shadow?
- Field 3 — last change date
- Field 4 — minimum password age (Correct answer)
- Field 5 — maximum password age
- Field 6 — warning period
Correct answer: Field 4 — minimum password age
The fourth field in /etc/shadow sets the minimum number of days a user must wait before changing their password again.
Question 7: A system administrator wants to list all users currently logged into the system. Which command provides this?
- lastlog
- who (Correct answer)
- getent passwd
- finger
Correct answer: who
The `who` command shows all users currently logged in, including their terminal and login time.
What is the effect of setting a user's shell to `/sbin/nologin`?