How to fix /etc/sudoers errors

Error 1

/etc/sudoers: syntax error near line 26 <<<
sudo: parse error in /etc/sudoers near line 26
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Solution 1A

Edit:

On your terminal type:

pkexec nano /etc/sudoers

It will open the file and you can edit now. To save and exit the file, just press:

Ctrl+X

And it will ask you if you wanna save the file. So type: Y and >Enter. Done!!!

Solution 1B

we have to write -

pkexec visudo

And it will open the file and one need to change as previous if any made.
Then type Ctrl+X which will ask to save the file. So type: Y and Enter

Source : sudo - How to fix /etc/sudoers: syntax error near line number - Stack Overflow


Error 2

sudo: error in /etc/sudo.conf, line 0 while loading plugin 'sudoers_policy'
sudo: /usr/lib/sudo/sudoers.so must only be writable by owner
sudo: fatal error, unable to load plugins
:~$ pkexec su
Error executing command as another user: Not authorized

This incident has been reported

Solution 2

$ su root     #enter password
$ chmod 644 /usr/lib/sudo/sudoers.so
$ chown -R root /usr/lib/sudo

If not, you’ll have to startup in recovery mode, get write permission on your disk, and change the mode of that file. RecoveryMode - Ubuntu Wiki

$ mount -o remount,rw /
$ chmod 644 /usr/lib/sudo/sudoers.so

Source : command line - Sudo comes up with an error, cannot run anything as root - Ask Ubuntu


If above solutions doesn’t work, reinstall !

1 Like