Ubuntu – Changed owner of /usr/bin

12.04sudo

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 🙂

Best Answer

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.

Related Question