Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
If you boot in single user mode and use visudo, then it won't let you save an incorrect file, so you will not be able to mess things up further. –  hexafraction Oct 30 '12 at 11:18
    
Thank you, how do I change the file, then? And, how exactly do I boot in single user mode? –  Robert Fáber Oct 30 '12 at 11:19
2  
@ObsessiveSSOℲ it would be nice to convert the comment to answer and let the questioner to mark it as the best answer. For future - help - others I mean. –  NikTh Oct 30 '12 at 12:14
1  
1  
On newer Ubuntu distributions, there's a simple solution (not requiring any reboot nor recovery), described here: askubuntu.com/a/73872 –  poldown Aug 28 at 11:23

4 Answers 4

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.

share|improve this answer
    
Shift didn't work for me, I had be pressing keys to get grub –  nafg Nov 19 '13 at 6:13
    
@nafg Every configuration is different. –  hexafraction Nov 19 '13 at 11:17

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.

share|improve this answer

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

share|improve this answer
1  
Follow up question: When I choose the Enable networking option, I'm prompted to tell the system that I'm sure. I do that and I just drop into nothing. No root prompt, nothing. What should I expect to see/do after the 2nd step? Thanks. –  Rob Wilkerson Jan 23 '13 at 14:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.