An administrator wishes to grant a user, john, the ability to restart the httpd service without providing a password. Which line should be added to the /etc/sudoers file to accomplish this?
You selected this option
john ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd
The correct line to add is john ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd. This allows the user john on all hosts (ALL) to execute the specific command /bin/systemctl restart httpd without being prompted for a password (NOPASSWD:). The ALL=(ALL) allows execution as all users and groups, although in this case, the specific command does not require changing to a different user or group. It's important to use full paths for commands in sudoers for security. The other options are incorrect because they either omit NOPASSWD: which would still prompt for a password, use ALL which would undesirably allow all commands, or specify an incorrect command path.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `NOPASSWD:` directive mean in the `/etc/sudoers` file?
Open an interactive chat with Bash
Why is it important to use full paths for commands in the `/etc/sudoers` file?
Open an interactive chat with Bash
What is the purpose of the `httpd` service in Linux?