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
Posts: 34762
Joined: Sun Jun 16, 2013 11:19 pm
Location: 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: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Posts: 3781
Joined: Wed Feb 04, 2015 6:38 pm

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.

Posts: 417
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

Don't run visudo on your Ubuntu notebook to fix things...

Code: Select all

[email protected]:~ $ 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

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

Return to “Troubleshooting”