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!

Ron Sebastian
  • 21
  • 1
  • 1
  • 4

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
    when i type su- it says: setgid: Operation not permitted @DrSAR can i login as guest and then do chown -R root:root /usr – Ron Sebastian May 24 '13 at 07: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 '13 at 07:51
  • what is a live CD? – Ron Sebastian May 24 '13 at 07:54
  • How did you install ubuntu? You can download a ubuntu image and burn it to CD or to a USB key (Startup Disk Creator). Put that into your computer and boot. Make sure the BIOS knows to boot from CD or USB (before looking at your harddisk). And when asked, say to Try Ubuntu. Don't say 'Install'. – DrSAR May 24 '13 at 07:55
  • 1
    ok, thankyou! it sure will help – Ron Sebastian May 24 '13 at 08:01
  • don't forget to upvote and mark as correct answer if it works. Also, you can edit your question if you have more information to add and require more help. – DrSAR May 24 '13 at 08:04
  • 1
    i cant upvote cuz i dont have required reputition but i accepted ur ans – Ron Sebastian May 24 '13 at 08:16
  • can you please give me the code to type in the terminal of the live cd to reset my current Ubuntu? @DrSAR – Ron Sebastian May 24 '13 at 10:10
  • I tried both your methods, i booted from a usb and changed the permissions but now a new problem arises, when i boot Ubuntu it says:""" The system is running in low-graphics mode

    Your screen, graphics cards, and input device settings could not be detected correctly. You will need to configure these yourself. """ i tried to press ctrl+alt+f2 (some ppl say f1 but mine works f2) and go to the console environment but when i press sudo it gives me same message @AJefferiss

    – Ron Sebastian May 24 '13 at 15:11
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
  • can you please tell how to boot from a disk? – Ron Sebastian May 24 '13 at 07: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 '13 at 07: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 '13 at 08:03
  • @user2243116 have a look at the wiki here: https://help.ubuntu.com/community/BootFromCD – AJefferiss May 24 '13 at 08: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 '13 at 08:10
  • @DrSAR, no worries just wanted to make sure I wasn't missing something! They are simpler commands, it's false of habit on my behalf to go with a find command instead... – AJefferiss May 24 '13 at 08:30