how to fix broken sudoers file without root

7.5k Views Asked by At

How to fix broken sudoers file in rhel6, it's not allowing me to get into sudo

 [bash ~]$ sudo su
sudo: >>> /etc/sudoers: syntax error near line 109 <<<
sudo: >>> /etc/sudoers: syntax error near line 109 <<<
sudo: parse error in /etc/sudoers near line 109
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I cannot edit this file as the permission is not there and this is virtual machine

2

There are 2 best solutions below

0
On

From the redhat docs

What can you do if you forget your root password? To reset it to a different password, boot into rescue mode or single-user mode, and use the passwd command to reset the root password.

then with root access you can fix the sudoers file

0
On

I know answering to this question is too late but it might be helpful to someone in the future.

instead of opening with sudo on terminal type visudo and edit the sudoers file.