Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This pertains to my Raspberry Pi, on which I have Raspbmc installed. I do realize that there is a Raspberry Pi StackExchange site, but I figured I might get more eyes on this problem here.

The issue is that I modified /etc/sudoers in an attempt to grant NOPASSWD permissions to one of the users, but I guess somewhere along the way I borked up the file and now I'm getting the following error whenever I login/attempt to use sudo:

sudo: parse error in /etc/sudoers near line 19
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I've found similar posts on Ubuntu as well as StackOverflow, but the problem is all the answers require a root password, and the root account is disabled by default on Raspbmc, and I obviously had not enabled it before attempting to change /etc/sudoers.

So my question is: how do I fix the file if I don't have root access enabled? Is it even possible?

share|improve this question
Don't forget to use visudo next time for editing. – slhck Dec 24 '13 at 12:50

You should still be able to boot up the Pi in Single User mode to get access to root.

Using another computer, modify cmdline.txt and add single to the end of the line
Then when you boot up the Pi from the SD card, it should automatically dump you to a root prompt which well allow you to update /etc/sudoers

share|improve this answer
Unfortunately I need root access to be able to modify /boot/cmdline.txt :( – 3cheesewheel Dec 24 '13 at 1:57
Hence using another computer – Lawrence Dec 24 '13 at 2:06
Raspberry Pi's hard drive is just SD card, so it is possible to plug it in via card reader to another computer and make all changes there without booting Pi in single mode. – VL-80 Dec 24 '13 at 2:19
@Nikolay Assuming the OP has another computer with Linux installed or has a Live Distro handy of course. – Lawrence Dec 24 '13 at 2:21
(Or Windows/OSX with VirtualBox; the "USB sharing" feature works well.) Though, single also asks for root password, so while it does allow logins to a locked or expired root account, it may still refuse access on occassion, so editing /etc/sudoers directly from the live system would be a bit easier and quicker. – grawity Dec 24 '13 at 2:56

The easiest solution is to boot up another OS on a LiveDVD or LiveUSB (ideally a LiveUSB, and ideally a Linux OS) then mount the disc and manually change the file. I've done similar things before and fixed it in this manner. All of your files will be visible and editable from the Live system. Unless you've encrypted the drive; that makes things a bit more complicated.

Let me know if you have questions and I'll edit this answer - I'm not sure how comfortable you might be with setting up a live USB, but it's not very hard.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .