LFCS · Question #767
You have a user whose account you want to disable but not remove. What should you do?
The correct answer is D. Edit /etc/passwd and insert an * after thefirst. Inserting an asterisk (*) into the password field of /etc/passwd or /etc/shadow effectively disables the account by making the password invalid.
Question
Options
- AEdit /etc/gshadow and just remove his name.
- BEdit /etc/passwd and change all numbers to 0.
- CEdit /etc/shadow and remove the last field.
- DEdit /etc/passwd and insert an * after thefirst : .
- EEdit /etc/group file and put a # sign in front of his name.
How the community answered
(47 responses)- A4% (2)
- C2% (1)
- D89% (42)
- E4% (2)
Why each option
Inserting an asterisk (`*`) into the password field of `/etc/passwd` or `/etc/shadow` effectively disables the account by making the password invalid.
Editing `/etc/gshadow` to remove a user's name would only affect group memberships for shadowed groups, not disable the user's login.
Changing all numbers to 0 in `/etc/passwd` would corrupt the user's UID, GID, and other fields, potentially rendering the account unusable and causing system issues, rather than simply disabling login.
Removing the last field from `/etc/shadow` (typically the expiry date) would not disable the password or account.
Inserting an asterisk (`*`) immediately after the first colon in the user's entry in `/etc/passwd` (or more commonly, replacing the encrypted password hash in `/etc/shadow` with `*` or `!`) makes the password invalid for authentication, effectively disabling the account without removing it.
Editing `/etc/group` and commenting out a user's name with `#` would not disable their login, it would only affect their group memberships.
Concept tested: Disabling a user account
Source: https://linux.die.net/man/5/passwd
Topics
Community Discussion
No community discussion yet for this question.