pror0ck
Posts: 2
Joined: Thu Jun 21, 2018 5:13 pm

/etc/sudoers: syntax error near line 28

Thu Jun 21, 2018 5:26 pm

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! :(

User avatar
DougieLawson
Posts: 39787
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

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

Thu Jun 21, 2018 6:06 pm

If you can still use sudo then run sudo visudo. That sanity checks your sudoers file before saving it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

jahboater
Posts: 6081
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

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

Thu Jun 21, 2018 6:27 pm

Flash another SD card with Raspbian and copy the file from that.

fbe
Posts: 645
Joined: Thu Aug 17, 2017 9:08 pm

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

Thu Jun 21, 2018 6:39 pm

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

pror0ck
Posts: 2
Joined: Thu Jun 21, 2018 5:13 pm

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

Fri Jun 22, 2018 3:25 pm

I copied the content to 010_pi-nopasswd and README and sudo works now. Thank you very much! :D

telecom
Posts: 59
Joined: Fri Feb 13, 2015 7:47 pm
Location: Toronto, Canada

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

Sun Sep 08, 2019 2:18 am

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

fbe
Posts: 645
Joined: Thu Aug 17, 2017 9:08 pm

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

Sun Sep 08, 2019 8:07 am

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.

Return to “Troubleshooting”