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 am trying to install a module using apt-get.

I do the following:
sudo apt-get install

But I get the following error:
sudo: can't stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting

I have been trying to google the answer but can't find any solution to the problem. How can I solve this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

sudo relies on a database of allowed users and actions in /etc/sudoers. This error occurs because this file does not exist, so sudo doesn't know who is authorized to do what.

You need to recreate /etc/sudoers with a valid configuration. Assuming you want to authorize users in group "sudo" to elevate to root, this would work (as root):

cat > /etc/sudoers << 'EOF'
root ALL=(ALL) ALL
%sudo ALL=(ALL) ALL
EOF

If you can't get a root shell any other way, or your root password is disabled, perhaps the easiest way to do this is to reboot, set init to your shell, then reboot again. For example, with GRUB 2, hit e at the bootloader to edit your menu entry, add init=/bin/bash to your kernel parameters, press F10 to boot, and run the above command from the shell that appears.

share|improve this answer
    
I can't become root by typing su. it says 'authentication failure'. But I can create directories with 'sudo mkdir somedirectory' for instance and my password gets accepted then. –  Hermann Ingjaldsson Feb 8 '13 at 11:40
1  
My favourite: sudo su - –  Munhitsu Feb 8 '13 at 11:52
2  
@jofel You can't do sudo foo if /etc/sudoers is missing... also you should not be doing those, it screws with the environment. Use sudo -i or sudo -s as appropriate. –  Chris Down Feb 8 '13 at 12:49
    
@ChrisDown Ok, my comment was not very clever (I deleted it). Why seems sudo mkdir work for Hermann Ingjaldsson if there is no /etc/sudoers file? –  jofel Feb 8 '13 at 14:54

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.