Courseiva
easyMultiple ChoiceObjective-mapped

XK0-006 Practice Question: A junior administrator accidentally modified the…

A junior administrator accidentally modified the /etc/sudoers file and now users report not being able to use sudo. Which command should be used to safely edit the sudoers file?

⚠ Common exam trap

Many candidates think any method that writes to the file (like `echo` or `chmod`) can fix the issue, but only `visudo` provides the syntax validation and locking necessary to safely edit the sudoers file without breaking sudo.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

visudo

The `visudo` command is the correct and safe way to edit the `/etc/sudoers` file because it locks the file against concurrent edits, performs syntax validation before saving, and prevents saving a malformed configuration that could break sudo entirely. This ensures that even if the administrator makes a mistake, the original valid file is preserved, avoiding the exact scenario described where users lose sudo access.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • visudo

    Why this is correct

    visudo safely edits /etc/sudoers with syntax checking and file locking.

  • chmod 400 /etc/sudoers

    Why it's wrong here

    Changing permissions does not repair syntax errors in sudoers.

  • echo 'user ALL=(ALL) ALL' >> /etc/sudoers

    Why it's wrong here

    Redirecting echo appends text without syntax checking, risking further breakage; visudo should be used.

  • usermod -aG wheel user

    Why it's wrong here

    Adding user to wheel group grants sudo access but does not fix the broken sudoers file.

About these practice questions

One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.