Linux User Management 2 — Questions and Answers
Question 1: Which file stores the encrypted password hashes for user accounts on a modern Linux system?
- /etc/passwd
- /etc/shadow (Correct answer)
- /etc/gshadow
- /etc/security/passwd
Correct answer: /etc/shadow
/etc/shadow stores encrypted password hashes and is readable only by root.
Question 2: What does the `-r` flag do when used with the `userdel` command?
- Renames the user account
- Removes the user's home directory and mail spool (Correct answer)
- Resets the user's password
- Revokes sudo privileges
Correct answer: Removes the user's home directory and mail spool
userdel -r removes the user account along with their home directory and mail spool.
Question 3: Which command would you use to lock a user account so they cannot log in?
- usermod -L username (Correct answer)
- passwd -d username
- chage -E 0 username
- userdel -l username
Correct answer: usermod -L username
usermod -L locks the account by prepending a '!' to the password hash in /etc/shadow.
Question 4: What is the default UID assigned to the root user on Linux?
- 1
- 0 (Correct answer)
- 1000
- 999
Correct answer: 0
Root always has UID 0, which grants it superuser privileges on the system.
Question 5: Which command displays the groups a specific user belongs to?
- getent group username
- id username
- cat /etc/group | grep username
- groups username (Correct answer)
Correct answer: groups username
The `groups username` command lists all groups the specified user is a member of.
Question 6: What happens when you run `useradd username` without any additional options?
- Creates user with home directory and bash shell
- Creates user with no home directory using system defaults (Correct answer)
- Prompts interactively for all user settings
- Creates user and sets a random password
Correct answer: Creates user with no home directory using system defaults
By default, useradd without -m does not create a home directory unless configured otherwise in /etc/default/useradd.
Question 7: Which field in /etc/passwd specifies the user's login shell?
- Field 5
- Field 6
- Field 7 (Correct answer)
- Field 4
Correct answer: Field 7
The seventh (last) field in /etc/passwd specifies the user's default login shell path.
Which file stores the encrypted password hashes for user accounts on a modern Linux system?