Bird
0
0

How can you allow a user to run only the systemctl restart apache2 command with sudo, without full root access?

hard📝 Application Q9 of 15
Linux CLI - Users and Groups
How can you allow a user to run only the systemctl restart apache2 command with sudo, without full root access?
AGive user full sudo access
BAdd user to root group
CAdd a line in sudoers: username ALL=(ALL) NOPASSWD: /bin/systemctl restart apache2
DUse sudo without restrictions
Step-by-Step Solution
Solution:
  1. Step 1: Understand sudoers command restriction

    You can restrict sudo to specific commands by editing sudoers file.

  2. Step 2: Analyze options

    Add a line in sudoers: username ALL=(ALL) NOPASSWD: /bin/systemctl restart apache2 correctly restricts sudo to only the specified command with no password prompt.

  3. Final Answer:

    Add a line in sudoers: username ALL=(ALL) NOPASSWD: /bin/systemctl restart apache2 -> Option C
  4. Quick Check:

    Restrict sudo by command in sudoers [OK]
Quick Trick: Restrict sudo commands in sudoers file [OK]
Common Mistakes:
MISTAKES
  • Adding user to root group
  • Giving full sudo access unnecessarily
  • Not restricting commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes