LX0-104 · Question #465
Of the ways listed, which is the best way to temporarily suspend a user's ability to interactively login?
The correct answer is C. Changing the user's shell to /bin/false.. To temporarily prevent a user from interactively logging in while preserving their account and files, modifying their shell is the most effective and least destructive method.
Question
Options
- AChanging the user's UID.
- BChanging the user's password.
- CChanging the user's shell to /bin/false.
- DRemoving the user's entry in /etc/passwd.
- EPlacing the command logout in the user's profile.
How the community answered
(30 responses)- A7% (2)
- B3% (1)
- C77% (23)
- E13% (4)
Why each option
To temporarily prevent a user from interactively logging in while preserving their account and files, modifying their shell is the most effective and least destructive method.
Changing a user's UID (User ID) would severely impact file ownership and permissions, potentially making their files inaccessible and causing system inconsistencies.
Changing the user's password would prevent them from logging in with their old password, but they could still log in if they learned the new one or if an admin provided it.
Changing a user's login shell to `/bin/false` (or `/sbin/nologin`) prevents them from establishing an interactive session, as these programs immediately exit upon execution. This approach maintains the user's account, files, and permissions, allowing for easy restoration of login access by changing the shell back.
Removing the user's entry in `/etc/passwd` would effectively delete the user account, which is a permanent and highly destructive action, not a temporary suspension.
Placing `logout` in the user's profile file (e.g., `~/.bash_profile`) would log them out immediately after login, but they might still briefly get a shell or cause issues with non-interactive processes.
Concept tested: Suspending user interactive login
Source: https://man7.org/linux/man-pages/man8/nologin.8.html
Topics
Community Discussion
No community discussion yet for this question.