Page 1 of 1

/etc/sudoers: syntax error near line 28

Posted: Thu Jun 21, 2018 5:26 pm
by pror0ck
Hello everyone!

I built C code in raspberry pi. When I'm trying to run program I get message:
/etc/sudoers: syntax error near line 27
sudo: parse error in /etc/sudoers near line 27
sudo: no valid sudoers sources found, quitting

I put cd card from raspberry pi to my Ubuntu laptop and looked at the file. This line is:
#includedir /etc/sudoers.d
This folder (/etc/sudoers.d) contains two files: README and 010_pi-nopasswd
I tried to open them with nano and both of them contains question marks. Don't know what that mean.
I tried to google the problem and everyone writes that you need to fix sudoers with an other computer with Linux, but I could not find an explanation how exactly It can be fixed.
Help me, please! :(

Re: /etc/sudoers: syntax error near line 28

Posted: Thu Jun 21, 2018 6:06 pm
by DougieLawson
If you can still use sudo then run sudo visudo. That sanity checks your sudoers file before saving it.

Re: /etc/sudoers: syntax error near line 28

Posted: Thu Jun 21, 2018 6:27 pm
by jahboater
Flash another SD card with Raspbian and copy the file from that.

Re: /etc/sudoers: syntax error near line 28

Posted: Thu Jun 21, 2018 6:39 pm
by fbe
the default content of /etc/sudoers.d/README on Raspbian is:

Code: Select all

#
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on
# installation of the package now includes the directive:
#
#       #includedir /etc/sudoers.d
#
# This will cause sudo to read and parse any files in the /etc/sudoers.d
# directory that do not end in '~' or contain a '.' character.
#
# Note that there must be at least one file in the sudoers.d directory (this
# one will do), and all files in this directory should be mode 0440.
#
# Note also, that because sudoers contents can vary widely, no attempt is
# made to add this directive to existing sudoers files on upgrade.  Feel free
# to add the above directive to the end of your /etc/sudoers file to enable
# this functionality for existing installations if you wish!
#
# Finally, please note that using the visudo command is the recommended way
# to update sudoers content, since it protects against many failure modes.
# See the man page for visudo for more information.
#
and /etc/sudoers.d/010_pi-nopasswd contains

Code: Select all

pi ALL=(ALL) NOPASSWD: ALL
Don't run visudo on your Ubuntu notebook to fix things...

Code: Select all

pi@raspberrypi:~ $ ls -la /etc/sudoers.d/
insgesamt 16
drwxr-xr-x   2 root root 4096 Apr 18 02:25 .
drwxr-xr-x 117 root root 4096 Jun 18 22:07 ..
-r--r-----   1 root root   27 Okt 18  2016 010_pi-nopasswd
-r--r-----   1 root root  958 Jun  5  2017 README

Re: /etc/sudoers: syntax error near line 28

Posted: Fri Jun 22, 2018 3:25 pm
by pror0ck
I copied the content to 010_pi-nopasswd and README and sudo works now. Thank you very much! :D

Re: /etc/sudoers: syntax error near line 28

Posted: Sun Sep 08, 2019 2:18 am
by telecom
Sorry for the late reply, but how did you copy?
I'm stuck with the same error, but can't edit file w/o the sudo...

Re: /etc/sudoers: syntax error near line 28

Posted: Sun Sep 08, 2019 8:07 am
by fbe
You need a machine with a card reader, where sudo works or where you can login as root.
The original poster has a notebook with Ubuntu. You could also use a Linux system, installed into a virtual machine on a Windows PC for that. If you have got an USB card reader, you could boot from a second SD card with working Raspbian to repair your broken configuration.