Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So I had no idea of the dangers of messing with the /etc/sudoers file, and was just trying to make a simple change in there. However, I seem to have put something with incorrect syntax in there, causing this problem:

$ sudo
sudo: >>> /etc/sudoers: syntax error near line 122 <<<
sudo: parse error in /etc/sudoers near line 122
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I can't edit the /etc/sudoers file anymore because I don't have root access.

One fix I see online is to use:

$ su -

and enter the root password. However, this amazon ec2 box doesn't seem to HAVE a root password, thus preventing me from using su -

The other thing I see is rebooting the computer and doing some single user stuff which allows you to reset the password. Big problem is that this is amazon ec2 and I'm just SSHing into the box, I don't have physical access.

Question, am I completely screwed or is there a possible workaround? This is not Ubuntu, it appears to be CentOS. I also understand now about visudo, but the site I had gotten the change from didn't mention that.

share|improve this question
    
There is an answer on Serverfault: serverfault.com/questions/392977/… –  derobert Oct 3 '13 at 22:51
add comment

1 Answer

Try this:

pkexec visudo

I have no idea if this will work on Amazon's EC2 services; I just found the answer here.

share|improve this answer
    
pkexec doesn't seem to work on CentOS –  Evan Oct 3 '13 at 22:38
    
Yeah, that's not too surprising. I just tried on RedHat which is basically the same as CentOS; pkexec is installed but not properly configured on this RH box. So it might work if it's properly configured. –  jayhendren Oct 3 '13 at 22:41
    
I get a command not found error. Did you see any sites that say anything about configuring pkexec? –  Evan Oct 3 '13 at 22:43
    
Ah, well "not working" is different from "not installed" ;) my pkexec is in usr/bin/, but that's probably already in your path, so it's likely the case that your CentOS box doesn't have pkexec. Try a locate pkexec just in case. –  jayhendren Oct 3 '13 at 22:46
    
thanks for your help yeah it doesn't have it. oh well looks like I have to spool up a new box. can't believe I broke everything so easily. –  Evan Oct 3 '13 at 22:49
show 1 more comment

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.