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?
john ALL=(ALL) NOPASSWD: ALL
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.
Why is specifying the full path to a command important in the /etc/sudoers file?
Open an interactive chat with Bash
What does the syntax 'john ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd' mean in detail?
Open an interactive chat with Bash
What is the role of 'NOPASSWD:' in a sudoers configuration?