A system administrator must allow a user named johndoe to run a backup script located at /usr/local/bin/backup.sh without being prompted for a password. The change must be made safely with automatic syntax validation. Which of the following lines should be added to the sudoers file using the visudo command?
johndoe ALL=(ALL) /usr/local/bin/backup.sh
ALL johndoe=(ALL) NOPASSWD: /usr/local/bin/backup.sh
The correct entry is johndoe ALL=(ALL) NOPASSWD: /usr/local/bin/backup.sh. It limits the privilege to the single backup script, sets the NOPASSWD tag so no password is required, and follows the correct sudoers syntax order (user hostlist = runaslist tag : command). Editing through visudo locks the file and refuses to save if a syntax error is detected, preventing configuration mistakes. The other options either omit the NOPASSWD tag, grant overly broad permissions, or place the fields in the wrong order, making them invalid or insecure.
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 is the purpose of the `visudo` command?
Open an interactive chat with Bash
Why is the `NOPASSWD` tag important in the sudoers file?