Question 241 · 300 in bank
A systems administrator wants to be sure the sudo rules just added to /etc/sudoers are valid. Which of the following commands can be used for this task?
Show answer
Answer: A
Explanation
A. visudo -c The visudo command is used to edit the /etc/sudoers file, and the -c option is used to check the syntax of the file without actually making any changes to it. If there are any syntax errors in the file, visudo will return an error message and prevent the changes from being saved. So, the command "visudo -c" can be used to validate the sudo rules in /etc/sudoers. Option B "test -f /etc/sudoers" checks if the file /etc/sudoers exists, but it does not validate the syntax of the file. Option C "sudo vi check" opens the file "check" with the vi editor, but it does not relate to the /etc/sudoers file. Option D "cat /etc/sudoers | tee test" displays the contents of the /etc/sudoers file and saves it to a file named "test", but it does not validate the syntax of the file.
Source: Adapted from community discussion — linux_admin
