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.

Eliah Kagan
  • 117,780

5 Answers5

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
Tim
  • 32,861
  • 27
  • 118
  • 178
RobotHumans
  • 29,530
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.)

Eliah Kagan
  • 117,780
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.

Eliah Kagan
  • 117,780
sayantankhan
  • 1,691
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.

brownian
  • 166
  • 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 '12 at 11:41
  • Try liveCD. Anyway, to run sudo you need to chmod 440 /etc/sudoers. – brownian Mar 23 '12 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!!!