Red Hat Certified System Administrator RHCSA · Free Practice Question Easy
Question 27
On ServerB, create a user sam with a UID of 1500, and ensure that he does not have access to any interactive shell on the system.
-
A
Pass
-
B
Fail
Reveal correct answer
Correct answer: A
Explanation
To configure a user with a specific UID and restrict access to an interactive shell, follow these steps:
Create the User:
Run the following command to create the user
samwith:UIDset to 1500Default shell set to
/sbin/nologin(restricting interactive access)
- # useradd -u 1500 -s /sbin/nologin sam
The option
-u 1500sets the user ID, and-s /sbin/nologinsets a non-interactive shell, preventing the user from logging in interactively.
Verify User Details:
Run the following command to display
sam's user and group IDs, confirming the correct UID:- # id sam
Additionally, you can check the user entry in the
/etc/passwdfile to confirm the shell and UID settings:- # tail -1 /etc/passwd
Attempt to Access
sam's Account:To further confirm restricted access, try switching to the
samaccount:- # su - sam
You should see a message indicating that access is denied or that
/sbin/nologinrestricts the shell.
Explanation:
Purpose of
/sbin/nologin:The
/sbin/nologinshell is commonly used to restrict shell access for system accounts or users who do not need interactive login capabilities. It displays a message denying access if someone tries to log in.
Why Set a Specific UID:
Assigning a specific UID, like
1500, ensures user management consistency, especially in environments where UID assignments may need to follow organizational standards or unique identification for users.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
