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
  • 3
    Please do not change permissions outside of your home. It will break your system to such an extent that a reinstall is much faster than any attemt to repair this.
    – Takkat
    May 24, 2013 at 7:44
  • @RonSebastian can you edit your question to include the commands you issued after the reboot from USB? Also, maybe try changing access permissions as I indicate in my question (after I edited it).
    – DrSAR
    May 24, 2013 at 16:27

2 Answers 2

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...

9
  • 1
    when i type su- it says: setgid: Operation not permitted @DrSAR can i login as guest and then do chown -R root:root /usr May 24, 2013 at 7:47
  • you will likely get a permissions error. try the live CD approach. you will be able to gain root status and should be able to modify permissions.
    – DrSAR
    May 24, 2013 at 7:51
  • what is a live CD? May 24, 2013 at 7:54
  • 1
    ok, thankyou! it sure will help May 24, 2013 at 8:01
  • 1
    i cant upvote cuz i dont have required reputition but i accepted ur ans May 24, 2013 at 8:16
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
6
  • can you please tell how to boot from a disk? May 24, 2013 at 7:53
  • the various find - chown commands are not recursive. So @user2243116 is at risk of not switching the permissions for some files that (s)he is interested in.
    – DrSAR
    May 24, 2013 at 7:58
  • @DrSAR can you explain why they're not recursive? I can't see why they wouldn't be. I've used a very similar command a number of times before to reset file permissions to 644 and it seems to have worked...
    – AJefferiss
    May 24, 2013 at 8:03
  • @user2243116 have a look at the wiki here: help.ubuntu.com/community/BootFromCD
    – AJefferiss
    May 24, 2013 at 8:03
  • @AJefferiss my bad. They are of course recursive. Sorry. However, why wouldn't you say sudo chmod -R root:root /mnt/recover/usr as well as sudo chmod -R a+rX /mnt/recover/usr ?
    – DrSAR
    May 24, 2013 at 8:10

You must log in to answer this question.

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