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
  • 32,167
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