55

I am getting this error:

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

I was trying to disable password authentication so I don't have to type password every time I want to install something, but I probably changed it in a not very good way. I am a newbie to Ubuntu, I got sick of Windows :)

So far I've found some people suggesting booting in single user mode, but I'm afraid of messing things up more.

How can I fix this error?

Alaa Ali
  • 32,213

6 Answers6

63

Fixing this is dead simple, and it is answered elsewhere on askubuntu.

Short answer, use:

pkexec editor_of_choice
NeilenMarais
  • 1,038
  • 10
  • 17
19

Hold Shift immediately while booting so that you get the GRUB screen. Select the recovery mode. Choose to drop to a root terminal. Run mount -n -o remount,rw / and then visudo. It'll let you fix your problems with the file and save. It won't let you save a malformed file.

nanofarad
  • 20,906
4

Folowing solution is for remote servers, it works!

http://ubuntuforums.org/showthread.php?t=2036382&p=12144840#post12144840

then just use visudo to add wheel, etc


  1. Rename your current file

    mv /etc/sudoers{,.bak}

  2. Create a new one vi /etc/sudoers with the following basic content:

    # /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
    # Host alias specification
    # User alias specification
    # Cmnd alias specification
    # User privilege specification
    root    ALL=(ALL) ALL
    # Allow members of group sudo to execute any command after they have
    # provided their password
    # (Note that later entries override this, so you might need to move
    # it further down)
    %sudo ALL=(ALL) ALL
    #
    #includedir /etc/sudoers.d
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    
  3. Run visudo and add your custom stuff.

Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
2

If u messed up your sudoers file.You'll need to:

  • Reboot into recovery mode (hit escape during boot, choose the recovery mode option on the grub screen)
  • Choose the 'Enable networking' option (if you don't your filesystem will be mounted as read-only. who knew)
  • Chosee the 'Drop to root shell' option
  • run visudo, fix your file
  • Reboot with normal grub option

source :- http://mario.net.au/content/recover-etcsudoers-ubuntu-1204

streak
  • 259
2

You can do this:

Create a copy

cp /etc/sudoers /etc/sudoers.bak

Edit problem parts there

vim /etc/sudoers.bak

Replace the origin sudoers file

cp /etc/sudoers.bak /etc/sudoers

It works for me.

ajile
  • 144
1

I screwed up the sudoers file to find out that I don't remember the root password. Solution: rebooted under Windows (I have a dual boot) and edited the file using ext2fsd (you have to reboot after the installation). In principle, this could be another Linux or a live flash, not necessarily Windows.