Linux User Management 3 — Questions and Answers
Question 1: What command sets a user's account expiration date to January 1, 2025?
- usermod -e 2025-01-01 username
- chage -E 2025-01-01 username (Correct answer)
- passwd --expire 2025-01-01 username
- useradd -x 2025-01-01 username
Correct answer: chage -E 2025-01-01 username
chage -E sets the account expiration date using YYYY-MM-DD format.
Question 2: Which command creates a new group called 'developers'?
- newgroup developers
- mkgroup developers
- groupadd developers (Correct answer)
- addgroup -n developers
Correct answer: groupadd developers
groupadd is the standard command to create a new group on Linux systems.
Question 3: What does the `/etc/skel` directory contain?
- Skeleton scripts for system services
- Template files copied to new users' home directories (Correct answer)
- Backup copies of deleted user accounts
- System-level shell configuration
Correct answer: Template files copied to new users' home directories
/etc/skel contains template files (like .bashrc) that are copied into a new user's home directory at creation.
Question 4: How do you add an existing user 'alice' to the supplementary group 'sudo' without removing her from other groups?
- usermod -g sudo alice
- usermod -aG sudo alice (Correct answer)
- groupmod -a alice sudo
- gpasswd sudo alice
Correct answer: usermod -aG sudo alice
usermod -aG appends the group without replacing existing supplementary group memberships.
Question 5: Which /etc/shadow field stores the number of days since epoch when the password was last changed?
- Field 1
- Field 2
- Field 3 (Correct answer)
- Field 4
Correct answer: Field 3
The third field in /etc/shadow records the date of last password change as days since January 1, 1970.
Question 6: What is the purpose of the `newgrp` command?
- Creates a new group
- Switches the active primary group for the current session (Correct answer)
- Lists new group memberships
- Renames an existing group
Correct answer: Switches the active primary group for the current session
newgrp changes the current user's active primary group for the duration of the shell session.
Question 7: Which command would you use to interactively change a user's password information including aging settings?
- passwd -i username
- usermod --password-info username
- chage -l username
- chage username (Correct answer)
Correct answer: chage username
Running chage without options prompts interactively to set all password aging parameters for the user.
What command sets a user's account expiration date to January 1, 2025?