Red Hat Certified System Administrator RHCSA · Free Practice Question Medium

Question 4

On ServerA, create a new user named "Samir" and grant him the ability to execute commands with root privileges using sudo. Ensure clarity, conciseness, and accuracy, and consider alternative approaches.

  • A

    Pass

  • B

    Fail

Reveal correct answer

Correct answer: A

Explanation

Step-by-Step Solution

Step 1: Create the User Account

  1. Command:

    • Explanation: Creates a new user account named Samir.

Step 2: Set the User's Password

  1. Command:

    • Explanation: This command assigns a password to Samir, enabling him to log in.

Step 3: Grant sudo Privileges to Samir

Choose one of the following methods:

  • Method A: Modify the sudoers File (For Granular Control)

    1. Open the sudoers File Using visudo:

      • Explanation: visudo opens the sudoers file in a safe environment, preventing syntax errors from locking you out.

    2. Add Sudo Permissions for Samir:

      • Add this line below the section “Allow root to run any commands anywhere”:

      • Explanation:

        • Samir: Specifies the user to grant permissions to.

        • ALL=(ALL): Allows Samir to run commands as any user or group.

        • ALL: Permits Samir to execute all commands.

      • Save and Exit: Press Esc, type :wq, and hit Enter.

  • Method B: Add Samir to the wheel Group (Simpler, if Applicable)

    1. Add Samir to the wheel Group:

      • Explanation: The wheel group typically has sudo privileges configured in /etc/sudoers, simplifying management for users who need full sudo access.

    2. Verify wheel Group Permissions in sudoers:

      • Ensure that the following line exists in /etc/sudoers to enable sudo for wheel group members:

Step 4: Verify Sudo Access

  1. Command:

    • Explanation: This lists the commands Samir can run with sudo, verifying that privileges are set up correctly.

Key Points and Best Practices

  • Understanding sudo Privileges:

    • Authentication: Samir will authenticate with his own password, not the root password, for security and accountability.

    • Logging: Commands executed with sudo are logged in /var/log/secure, which helps in tracking privileged actions.

    • Password Timeout: By default, sudo sessions last for 5 minutes of inactivity before requiring re-authentication.

  • Alternative Options:

    • Limiting Privileges: For limited sudo access, grant Samir permission only for specific commands. For example:

      • Explanation: This allows Samir to run systemctl commands without a password prompt, while restricting access to other commands.

  • Security Considerations: Carefully assess the need for sudo privileges, especially if full access is unnecessary, as excessive privileges can pose security risks.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need