Linux User Management 4 — Questions and Answers
Question 1: What numeric UID range is typically reserved for system accounts on Linux?
- 0–499 or 0–999 depending on distro (Correct answer)
- 1000–1999
- 500–999 only
- 1–99 only
Correct answer: 0–499 or 0–999 depending on distro
System accounts typically use UIDs below 500 (Red Hat/CentOS) or below 1000 (Debian/Ubuntu), with regular users starting above that threshold.
Question 2: Which file must be edited to change the default shell for new users created with useradd?
- /etc/profile
- /etc/default/useradd (Correct answer)
- /etc/login.defs
- /etc/shells
Correct answer: /etc/default/useradd
/etc/default/useradd contains defaults like SHELL, HOME prefix, and SKEL path used by useradd.
Question 3: A user's account is locked. Which command unlocks it?
- passwd -u username
- usermod -U username
- chage -l username
- Both A and B (Correct answer)
Correct answer: Both A and B
Both `passwd -u` and `usermod -U` unlock a locked account by removing the '!' prefix from the password hash.
Question 4: What does the `getent passwd username` command do?
- Retrieves the encrypted password for a user
- Fetches user account information from all configured name service databases (Correct answer)
- Lists all users with passwords set
- Displays password policy for the user
Correct answer: Fetches user account information from all configured name service databases
getent queries the Name Service Switch (NSS) databases including /etc/passwd, LDAP, and NIS for the specified user.
Question 5: Which command renames the user 'bob' to 'robert' and also renames their home directory?
- usermod -l robert -d /home/robert bob
- usermod -l robert -m -d /home/robert bob (Correct answer)
- useradd -l robert bob
- rename-user bob robert
Correct answer: usermod -l robert -m -d /home/robert bob
usermod -l changes the login name, -d sets the new home path, and -m moves the existing home directory contents.
Question 6: What does the GECOS field in /etc/passwd typically store?
- Encrypted password
- User's full name and contact information (Correct answer)
- Group ID
- Home directory path
Correct answer: User's full name and contact information
The GECOS field (field 5) stores user information like full name, office, phone number, separated by commas.
Question 7: Which command forces a user to change their password at next login?
- passwd -e username
- chage -d 0 username
- usermod --expire-password username
- Both A and B (Correct answer)
Correct answer: Both A and B
Both `passwd -e` and `chage -d 0` expire the password immediately, forcing a change at next login.
What numeric UID range is typically reserved for system accounts on Linux?