LFCS · Question #110
Which of the following steps prevents a user from obtaining an interactive login session?
The correct answer is A. Run the command chsh -s /bin/false with the user name. To prevent a user from initiating an interactive login session, their default shell can be changed to a non-interactive shell like /bin/false using the chsh command.
Question
Options
- ARun the command chsh -s /bin/false with the user name.
- BSet the UID for the user to 0.
- CRemove the user from the group staff.
- DAdd the user to /etc/noaccess.
- ECreate a .nologin file in the user's home directory.
How the community answered
(65 responses)- A89% (58)
- C2% (1)
- D3% (2)
- E6% (4)
Why each option
To prevent a user from initiating an interactive login session, their default shell can be changed to a non-interactive shell like `/bin/false` using the `chsh` command.
Changing a user's login shell to `/bin/false` (or `/sbin/nologin`) with `chsh -s /bin/false <username>` effectively prevents them from starting an interactive shell session, as `/bin/false` simply exits immediately. This is a common method for disabling interactive logins for service accounts.
Setting a user's UID to 0 would grant them root privileges, not prevent them from logging in; it would give them full system access.
Removing a user from a specific group like `staff` only affects their group-based permissions, not their ability to log in interactively.
`/etc/noaccess` is not a standard Unix/Linux mechanism for preventing user logins; this might be specific to other Unix variants or non-standard configurations.
Creating a `.nologin` file in a user's home directory does not universally prevent interactive login sessions; the `/etc/nologin` file typically applies globally to prevent *all* non-root users from logging in.
Concept tested: Linux user account security (disabling interactive login)
Source: https://man7.org/linux/man-pages/man1/chsh.1.html
Topics
Community Discussion
No community discussion yet for this question.