CompTIA Linux+ (XK0-005) — Question 206
A Linux user is trying to execute commands with sudo but is receiving the following error:
$ sudo visudo
>>> /etc/sudoers: syntax error near line 28 <<<
sudo: parse error in /etc/sudoers near line 28
sudo: no valid sudoers sources found, quitting
The following output is provided:
# grep root /etc/shadow
root:*LOCK*:14600::::::
Which of the following actions will resolve this issue?
Answer options
- A. Log in directly using the root account and comment out line 28 from /etc/sudoers.
- B. Boot the system in single user mode and comment out line 28 from /etc/sudoers.
- C. Comment out line 28 from /etc/sudoers and try to use sudo again.
- D. Log in to the system using the other regular user, switch to root, and comment out line 28 from /etc/sudoers.
Correct answer: B
Explanation
The correct answer is B because booting in single user mode allows you to access the system as the root user without needing sudo, enabling you to safely edit the sudoers file. Option A is incorrect because direct root login is not always possible if the root account is locked. Options C and D would still require sudo privileges, which are not available due to the syntax error.