7

I did it... I guess everyone does it sometime, but this was my first. I executed sudo chown -R /usr/bin and before I realized my mistake, it was too late... Now I can't access sudo because I receive the following error: sudo: must be setuid root. I would really appreciate if I could avoid a complete reinstall of ubuntu because that would require far too much work :(

Here is the commands I've tried without success (in recovery mode):

chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo

I've also tried chmod 0440 /etc/sudoers all without success. Any ideas about what I can try to fix it?

NOTE: Sorry for creating another one of these threads, but since I knew the exact command I executed to blow it all up, I thought that might make a difference :)

Elliott Darfink
  • 193
  • 2
  • 8
  • I think you might want to try booting a live CD/USB and chooting into your existing installation to fix things... Just an idea. – RobinJ May 05 '12 at 22:35

1 Answers1

3

Just use any live cd to boot into recovery and then select the hard disk and navigate to the bin folder of your installed ubuntu. Then reset the permissions like this: go to the root console. Once there, execute the following to return permissions back:

chmod 755 /bin\

EDIT: Just go to terminal from any live cd and write there:

sudo fdisk -l 

This will list out all the partitions. Just locate the root partition of the drive and write down its device name. It will have the device listed out in order:

/dev/sda1
/dev/sda2
/dev/sda3
....
....

Just note down the device name of your root partition, let you can use Gparted to examine the partitons in a better way. But finding out the root partition is what you all care about. Now suppose /sda2 is your root partition(I assume). Just go to terminal and mount the device by

sudo mkdir /mnt //in case live cd does not have /mnt folder.
sudo mount /dev/sda2

Now when you get your device mounted, Just navigate to it as:

sudo lshw 

and note down the root device serial number

cd /media
cd device-logical-number  // for ex- mine have A272B6CF72B6A785

and now you can cd to bin directory and can apply permission there.

ashutosh
  • 1,292
  • I cannot use the recovery console for this? And if I may ask, with 'go to the root console' do you mean sudo su? EDIT: And I guess a USB would work just as fine? – Elliott Darfink May 05 '12 at 23:10
  • yeah a usb or anything that can lead you to the terminal of live cd of ubuntu could be good. – ashutosh May 05 '12 at 23:14
  • Just so I don't make any mistakes. Should I boot from the usb, cd to /bin (on my installed harddrive) and execute chmod 755 /bin? And am I super user automatically or do I need to execute sudo su or something similiar? – Elliott Darfink May 05 '12 at 23:27
  • yeah you got me. Just boot from the USB or CD and go to terminal and just access the drive on which you have ubuntu installed on and change the permission from there as the root. You need to be root to make the changes – ashutosh May 05 '12 at 23:28
  • Writing from my phone. How do I cd into my hard drive/mount it? – Elliott Darfink May 05 '12 at 23:35
  • I am now editing my answer for the procedure. – ashutosh May 05 '12 at 23:36
  • Okay, I mounted my hard drive, and cd'ed into /mnt/bin. I tried to execute chmod 755 /bin, but whenever I had that backslash, it asked me to specify a directory, which didn't make any sense. So I used without the backslash (chmod 755 ../bin) and I still haven't got a functional sudo (same error). Did I do something wrong or is it a dead-end? – Elliott Darfink May 05 '12 at 23:50
  • just edited for what you are looking for, if you consider it worth for, then do not hesitate it making an answer. It can help many. – ashutosh May 05 '12 at 23:59
  • This does not address the problem. The permissions of all files under /usr/bin have been messed up and they are not all the same. The only sane way of fixing this is to reinstall. – psusi Dec 01 '14 at 04:02