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.

I recently started messing with some files on a virtual hosted machine and I was logged in a normal/non-root user. At first everything was fine, I was able to install anything I needed using:

sudo apt-get install tree

But I somehow messed up a file where now when I do that I get the following error:

sudo: can't open /etc/sudoers: Permission denied

I'm not sure how to diagnose this, I've googled for solutions but everything's about what sudo is and nothing related to what to do about re-enabling users to use it.

Let me know if you'd like any other details in comments :)

Edit:

ls -l /etc/sudoers
-r--r----- 1 root root 577 Apr 20 03:42 /etc/sudoers
share|improve this question
    
Login as root and tell us what this looks like: ls -l /etc/sudoers –  Caleb Apr 20 '11 at 9:29
    
just added it to the edit –  Muhammad Usman Apr 20 '11 at 9:36
    
Hmm. That's still not giving up any clues. How about ls -l /usr/bin/sudo (or wherever which sudo tells you the sudo executable is at) –  Caleb Apr 20 '11 at 9:39
1  
This could happen if there is a problem with group permissions. Did you recently make any changes to /etc/group? Did you install sudo using your own ./configure arguments? Is group 0 root or wheel? If it's wheel, you'll need to run chgrp wheel /etc/sudoers as root. –  Mikel Apr 20 '11 at 9:48
1  
What virtualization technology? Is SELinux or AppArmor active? –  Gilles Apr 20 '11 at 20:52
show 2 more comments

2 Answers 2

There's a lot of things that could be failing, but given your output of ls -l /etc/sudoers, most of them are ruled out.

First a couple of quick checks:

  1. what does type sudo print?
  2. what does getent group 0 print?

Then, to properly see what's going on, can you log in as root using su -, then run this?

# apt-get install ltrace
# ltrace -u <username> sudo true 2>&1  | egrep '(sudo|stat|set.*[ug].*id)'

and/or

# apt-get install strace
# strace -u <yourusername> sudo true 2>&1 | egrep '(sudo|set.*[ug].*id)'

And add the output to your question.

share|improve this answer
add comment

As a last resort, you can copy the /etc/sudoers file to a backup location, then apt-get --reinstall install sudo

share|improve this answer
add 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.