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 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?

share|improve this question
8  
That's why you're supposed to use visudo for editing /etc/sudoers –  Sergey Jul 31 '12 at 3:48
    
related question -> what-are-the-differences-between-sudo-su-visudo-chroot-and-gksu –  hhlp Jan 2 '13 at 17:47

4 Answers 4

up vote 5 down vote accepted

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

Need write permission to edit sudoers so, mount -o remount,rw /

Then nano /etc/sudoers and revert your mistake.

share|improve this answer
2  
Please include in your answer an advice to use visudo to make any change to the sudoers file. –  Eric Carvalho Jul 31 '12 at 1:24
    
@EricCarvalho thank you friend –  Dominic Jul 31 '12 at 17:34
    
@Cumulus007 thank you friend –  Dominic Jul 31 '12 at 17:34

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 
share|improve this answer
    
No joy; The program 'pkexec' is currently not installed. You can install it by typing: sudo apt-get install policykit-1 –  Koen. Nov 12 at 22:37

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.

share|improve this answer
    
thank you friend –  Dominic Jul 31 '12 at 17:32
2  
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

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

EDITOR=gedit visudo

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

share|improve this answer
    
thank you friend –  Dominic Jul 31 '12 at 17:33

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.