Validate the default sudoers file and included files without changing the configuration.
Which command is appropriate?
visudo -c parses sudoers in check-only mode and reports syntax, ownership, and mode problems.
Detailed explanation
sudo -cIncorrect. sudo -c is not the sudoers syntax-check option.
Incorrect. sudo -c is not the sudoers syntax-check option.
cat /etc/sudoersIncorrect. cat only prints contents.
Incorrect. cat only prints contents.
sudo -lIncorrect. sudo -l lists policy for a user.
Incorrect. sudo -l lists policy for a user.
visudo -cCorrect. visudo -c validates sudoers syntax.
Correct. visudo -c validates sudoers syntax.
Try it yourself
An example you can run in a temporary verification environment.
visudo -h 2>&1 | grep -E -- '-c|--check' | head -n 1Expected result
-cまたは--checkの説明行Key points
- visudo is the dedicated parser
- -c means check
- Avoid direct edits
Notes
- Environment: sudo visudo help / sudoers読取・変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.