11

I accidentally did chmod -777 / now I can't access anything, when I restart a dialog is shown saying "your graphics is set to low", after giving ok, then there is an option " exit to login screen" when I select this I get a blank screen with "-" on top.

Is there any way to revert this process or at least to recover the data ?

P.S: I m using windows vista and Ubuntu 13.04 (dual boot).

YasirAzzu
  • 261

3 Answers3

8

Note that chmod -777 is like chmod 000. So the OP has probably just changed the permissions of the / folder, not recursively, and he or she can recover the system simply with a

chmod 755 /

from a recovery boot. For example, boot from the installation media, choose try Ubuntu, open a terminal and go superuser (do the following checking thrice and only after having understood what you are doing)

sudo -i
mount /dev/yourrootpartitonhere /mnt
cd /mnt
chmod 755 .
cd ..
umount /mnt

And reboot normally, all should be OK.

If you did use -R, do a backup of your data (see other answers here), and reinstall.

Rmano
  • 31,947
  • Hi Rmano, thanks for you answer I followed your instructions but it didn't work – YasirAzzu May 25 '14 at 08:55
  • I did every thing Rmano said I didn't get any error ( except after ' chmod 755 .' I did ' cd .. ' to come out of mnt ), nothing changed I m getting the same dialog box after reboot – YasirAzzu May 25 '14 at 16:46
  • Are you sure you mounted your correct root partition? – Rmano May 25 '14 at 20:05
  • Yes I did correctly, I mounted the ' / ' partition – YasirAzzu May 26 '14 at 17:07
  • 1
    If you booted from recovery media, the '/' partition is not the partition you want, but rather the root of the recovery media. You have to find your HD, and find the root of your actual HD, rather than your recovery root. – daviewales May 28 '14 at 11:49
  • @daviewales correct - this is what I described. After the mount, moving to the mounted directory and changing the props of . will in fact change the props of the mounted Dir, which will the be root when the system is rebooted normally. I really do not know why it didn't work. – Rmano May 28 '14 at 18:28
  • I'm guessing he didn't mount the correct partition... – daviewales May 29 '14 at 04:52
  • @daviewales I have mounted my partition correctly, i did sudo fdisk -l found my root partition – YasirAzzu May 31 '14 at 04:01
  • OK. In that case, I don't know what's going on. – daviewales May 31 '14 at 04:51
4

Thanks for your answers.

I freshly installed Ubuntu 14.04, however I was able to backup my data using live CD.

I booted from a live CD and I did chmod 777 / 'pathOfTheDirectory'

Do not mess with things in which you don't have much knowledge - lesson learned.

YasirAzzu
  • 261
1

If you ran the command chmod -777 /foo, it could have some weird functionality. Most likely, it will negate the bits you are passing in the octal negation of 777 (which is 111111111 in binary, which is important), which is not actually possible to represent, since chmod is using a 9 bit set for file permissions (1 bit per permission for read, write, execute * owner,group,user), which is an unsigned number (cannot be negative).

Let's assume that you can represent signed numbers (negative and positive values). If you find 2's complement of 777 (0b111111111), then you can figure out the exact behavior of (and number you are passing to) the command:

 111111111
-000000000
----------
 111111111
+000000001
----------
1000000000 #this number will cause an overflow because it is 512
           #since our range is only -256 -> 255

What does all this mean? You told the kernel "Hey, make the permissions for this folder 1000000000". The kernel responded with "Ok" and did what you asked. Now your filesystem permissions are exactly that, --------- root root /. This is all assuming that I (and your kernel/CPU) did the math correctly.

Recovery

The root filesystem's (what / is) default permissions are usually 755. The easiest way to fix this is to log in and switch to tty using Ctrl+F1 (which will take you to tty1, tty2-6 are open as well, with tty7 being the location of the current X session). You can log in as root (or as a regular user, but use sudo before each command below) and run this command:

chmod 755 /

That should fix the issue you are having.

ChrisR.
  • 527
  • 4
  • 7
  • Hi ChrisR, thanks for your answer. When run sudo chmod 755 / I get "sudo: effective uid is not 0, is sudo installed setuid root?" When I tried without sudo I got "chmod: changing permission s of '/': operation not allowed". – YasirAzzu May 25 '14 at 09:04
  • If you know root's password, you can just su, enter the root password, and run the command as root. – ChrisR. May 25 '14 at 18:49
  • 2
    You can't use sudo until you fix your / permissions... so the need to do that from a recovery environment. – Rmano May 25 '14 at 20:09
  • @ChrisR I don't know root password, is there something like default password – YasirAzzu May 26 '14 at 17:05
  • If you never set it up, and your system is in it's current state, you have one of two options: 1) load the Ubuntu Live CD or 2) Install from scratch. – ChrisR. May 26 '14 at 18:23