RHCE User and Group Management 2 — Questions and Answers
Question 1: Which command locks a user account to prevent login?
- usermod -L jdoe
- passwd -l jdoe
- chage -l jdoe
- Both A and B (Correct answer)
Correct answer: Both A and B
Both `usermod -L` and `passwd -l` lock a user account by prepending `!` to the password hash in `/etc/shadow`.
Question 2: What is the default UID range for regular users in RHEL 8?
- 1–499
- 500–999
- 1000–60000 (Correct answer)
- 100–65534
Correct answer: 1000–60000
In RHEL 8, regular users are assigned UIDs starting at 1000, as defined in `/etc/login.defs`.
Question 3: Which command changes the primary group of user `jdoe` to `developers`?
- usermod -g developers jdoe (Correct answer)
- usermod -G developers jdoe
- groupmod -u developers jdoe
- gpasswd developers jdoe
Correct answer: usermod -g developers jdoe
`usermod -g` changes the primary (login) group of the specified user.
Question 4: Which file defines defaults like `PASS_MAX_DAYS` for new user accounts?
- /etc/pam.d/system-auth
- /etc/security/limits.conf
- /etc/login.defs (Correct answer)
- /etc/default/useradd
Correct answer: /etc/login.defs
`/etc/login.defs` contains system-wide defaults for user account creation including password aging policies.
Question 5: What command deletes user `jdoe` along with their home directory?
- useradd -d jdoe
- userdel -r jdoe (Correct answer)
- usermod -d jdoe
- deluser --remove-home jdoe
Correct answer: userdel -r jdoe
`userdel -r` removes the user account and recursively deletes their home directory and mail spool.
Question 6: Which command displays password aging information for user `jdoe`?
- passwd -S jdoe
- chage -l jdoe (Correct answer)
- getent shadow jdoe
- cat /etc/shadow | grep jdoe
Correct answer: chage -l jdoe
`chage -l` lists the password aging information for a user in a human-readable format.
Which command locks a user account to prevent login?