1

I screwed up big time. I changed the permission of /etc in ubuntu 11.10 by using following command

sudo chmod 665 /etc

now when ever i try to use sudo it gives the following error:

sudo: can't open /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting

Any help will be greatly appreciated because i am new to Ubuntu. I have already tried using su but it doesnt even login as root and even i give it the right password it always say Authentication Failure. I don't want to login as root coz its risky and even a newbie in Linux like me is not stupid enough to have such control. I just want to use my sudo again. I have tried to go into recovery mode as well but I can't get in to recovery mode.

0

5 Answers 5

7

Boot the recovery console option.
Select remount read-write
Select root shell

cd /
chmod 755 etc <--to get it back to default  
sync
init 6
8
  • i dont know how to boot the recovery console option....i am really sorry but could you give me some hints on how to do it...i.e. boot the recovery console option?
    – GuruDevil
    Mar 23, 2012 at 11:42
  • 1
    You got the arguments the wrong way around there. chmod 755 /etc
    – geirha
    Mar 23, 2012 at 11:49
  • thanx for the help......my problem is fixed.....happy coding
    – GuruDevil
    Mar 23, 2012 at 13:36
  • I think that should be /etc?
    – Tim
    Aug 16, 2014 at 9:11
  • 1
    @Tim Changed directory to / first. Don't like absolute urls. Aug 16, 2014 at 9:58
3

You can generally fix this sort of problem without booting into recovery mode, without using a live CD, and without rebooting at all. An Ubuntu system with a GUI (as opposed to an Ubuntu Server system with no GUI installed) has two mechanisms for running commands as root. One is sudo. The other is PolicyKit. You can use pkexec, the command-line frontend to PolicyKit, to fix the permissions:

pkexec chmod 755 /etc

If all you did to create the problem was to run sudo chmod 665 /etc, then that completely fixes the problem and you don't need to try to repair any permissions inside /etc. (Nothing inside /etc is changed with a chmod command on /etc that doesn't use the -R flag.)

1
  • +1 for pkexec: surely the most easy and quick way to solve the problem. Jan 12, 2013 at 9:21
1

Try inserting the the ubuntu live cd, open up the terminal and enter

  1. sudo su -
  2. mount /dev/sda5 (or whichever is the root partition of your Ubuntu installation) /mnt
  3. chroot /mnt
  4. chmod 755 /etc
  5. exit

This should make things as they were.

0
0

You need to chmod 440 /etc/sudoers. Try to do this in rescue mode or pass init=/bin/bash to boot command line. Ask if you need more info.

2
  • well to be honest i dont know how to go in rescue mode.....i know this is a stupid question but please tell me how to go in rescue mode.....boot menu shows 2 options only Windows7 ubuntu
    – GuruDevil
    Mar 23, 2012 at 11:41
  • Try liveCD. Anyway, to run sudo you need to chmod 440 /etc/sudoers.
    – brownian
    Mar 23, 2012 at 14:42
0

your boot-manager-OS-List looks like the windows-bootmanager, not the ubuntu-grub-bootmanager, which would give you the option to get into recovery mode.

i don't actually know if the system installs grub anywhere anyway, but when you select ubuntu try holding shift to get into the grub-menu (if existent).

Another way would be to edit the boot.ini-file on your windows-partition. There should be an entry for ubuntu. Try appending an 1 to this line and boot into ubuntu. The 1 ends you up in single-user-mode - a command line with root-access to your system.

But the easiest way is a life-CD for sure!!!

You must log in to answer this question.

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