nerdexam
CompTIA

XK0-005 · Question #605

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…

The correct answer is B. Boot the system in single user mode and comment out line 28 from /etc/sudoers. A syntax error in /etc/sudoers combined with a locked root account prevents sudo from working, requiring special boot modes to fix the configuration.

Troubleshooting

Question

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?

Options

  • ALog in directly using the root account and comment out line 28 from /etc/sudoers.
  • BBoot the system in single user mode and comment out line 28 from /etc/sudoers.
  • CComment out line 28 from /etc/sudoers and try to use sudo again.
  • DLog in to the system using the other regular user, switch to root, and comment out line 28 from

How the community answered

(18 responses)
  • A
    6% (1)
  • B
    78% (14)
  • C
    6% (1)
  • D
    11% (2)

Why each option

A syntax error in `/etc/sudoers` combined with a locked root account prevents `sudo` from working, requiring special boot modes to fix the configuration.

ALog in directly using the root account and comment out line 28 from /etc/sudoers.

Logging in directly as root is impossible because the root account is explicitly locked, as shown by `grep root /etc/shadow`.

BBoot the system in single user mode and comment out line 28 from /etc/sudoers.Correct

Since `sudo` is broken and the `root` account is locked (`*LOCK*` in `/etc/shadow`), the administrator cannot gain root privileges through normal means. Booting into single-user mode (or rescue mode) provides a root shell, bypassing the `sudoers` file, allowing the problematic line 28 in `/etc/sudoers` to be commented out or corrected.

CComment out line 28 from /etc/sudoers and try to use sudo again.

The user cannot comment out line 28 from `/etc/sudoers` because `sudo` is broken, and they don't have root privileges to edit the file directly.

DLog in to the system using the other regular user, switch to root, and comment out line 28 from

Switching to root from another regular user requires sudo or a root password, neither of which is available due to the sudo error and locked root account.

Concept tested: Recovering from broken sudoers file

Source: https://www.redhat.com/sysadmin/recover-root-password

Topics

#sudo configuration#system recovery#single user mode#access control

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice