14

I edited my sudoers file in /etc and after that I can't use sudo anymore. I get this whenever I issue the command:

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

How to solve it?

Eric Carvalho
  • 54,385
Dominic
  • 147

5 Answers5

27

Had the same problem,

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

Easier way to fix it is :

pkexec visudo 
wedgess
  • 271
10

Boot into recovery mode from the GRUB menu (hold the SHIFT key during boot to reveal this menu), enter the root shell.

  1. First you need write permission to edit sudoers, so run

    mount -o remount,rw /
    
  2. Then use visudo and revert your mistake. visudo will check if the resulting sudoers file conforms to the required syntax.

    By default visudo uses vi as editor, but you can tell it to use your favourite text editor with the EDITOR environment variable, e. g.:

    EDITOR=nano visudo
    
David Foerster
  • 36,264
  • 56
  • 94
  • 147
2

This fixed the same problem for me:

pkexec chmod 440 /etc/sudoers

pkexec chmod 775 /etc/sudoers.d

pkexec chmod 440 /etc/sudoers.d/README
t013463
  • 21
1

You could also edit /etc/sudoers with any text editor you like:

EDITOR=gedit visudo

would use gedit for it. But you should run it from shell. Otherwise you wouldn't be able to read error-Messages.

muru
  • 197,895
  • 55
  • 485
  • 740
gemue2010
  • 374
1

Below is the default sudoers file for Ubuntu:

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults    env_reset

# Uncomment to allow members of group sudo to not need a password
# %sudo ALL=NOPASSWD: ALL

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

I hope it will help you my friend.

Eliah Kagan
  • 117,780
  • 3
    As of Ubuntu 12.04, this is no longer the default (since sudo is now the group that confers administrative abilities, though in upgraded systems admin still exists and serves its usual function). – Eliah Kagan Aug 31 '12 at 22:37