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.
sudo chmod -R 777 /
orsudo chmod 777 /
? – TuKsn May 24 '14 at 17:51chmod
with777
? – Mateo May 24 '14 at 19:11chmod -777
is likechmod 000
... Although it is not in the manual. Bug or hidden feature? – Rmano May 25 '14 at 05:22chmod 0
anymore. chmod -777 is much better - it must be, or why else would it be there. :-) – Marty Fried May 25 '14 at 20:48