2

I wanted to move a file to a /usr/python2.7/ but i was unable to do so, so i changed the permissions of /usr to myuser:

sudo chown -R ***** /usr

it worked but i realised it was a blunder when sudo stopped working after that. It says:

sudo: effective uid is not 0, is sudo installed setuid root?

I have seen this post where the accepted solution was to use the policykit:

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

however, even the policykit is saying that:

pkexec must be setuid root

please help, i've learned a lesson and will never change permissions for /usr again. Please help me this time!

2 Answers2

2

If you're root account is not disabled, you should be able to become root:

su -

After that you should be able to change the ownership of /usr again.

If that doesn't work (because you did not enable a root account + password), you can boot from a live cd (a usb stick or CD you might still have lying around from your ubuntu installation will work).

Boot it, and mount your current hard drive (maybe at /media/raring-root-disk). Then change the ownership of that mounted partition:

chown -R root:root /media/raring-root-disk/usr
chmod -R a+rX /media/raring-root-disk/usr

Note: I didn't test this, so the live-CD approach (though favoured by me) might not work. However, I can not see how it can harm your situation. Make sure you have backups since you might need them anyway if you find you'll be re-installing this all...

DrSAR
  • 2,132
1

With a Ubuntu LiveCD you can reset the permissions. What you need to do is boot onto the CD and open a terminal.

Within the opened terminal you need to find what drive your partition is on, you can do that using sudo fdisk -lu. The output will show something similar to the following:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000be1b6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   943300607   471649280   83  Linux
/dev/sda2       943302654   976771071    16734209    5  Extended
/dev/sda5       943302656   976771071    16734208   82  Linux swap / Solaris

My root partition here is sda1, if you've only got 1 drive on it I would presume yours is something similar. But if you're unsure, you're looking for the device which has the System column set to "Linux".

Once you know the partition that you're Ubuntu is installed into you, you need to mount it, replace /dev/sda1 with your device in the following:

sudo mkdir /mnt/recover
sudo mount /dev/sda1 /mnt/recover
sudo chmod -R root:root /mnt/recover/usr
sudo chmod -R a+rX /mnt/recover/usr
sudo umount /mnt/recover
AJefferiss
  • 1,154
  • 9
  • 17