I accidentally did a sudo chmod -R 777 . in /var/www/html/mysite folder. What will it result to?

I wanted to save some time by not changing my folder before running the command as well as not typing the full path as I was in current directory where I wanted to change.


That command will change permissions to anything inside /var/www/html/mysite to read, write, execute for owner, group and others. You basically void all form of security.

In case anyone from the outside world gets access to your system they can do anything with these files. Including deleting them.

By the way: I consider this also bad for a development server.

  1. how are you suppose to decide if some script will work on an active server. It might be that the "777" on the development server make it seem like something is working properly but it is not.
  2. what do you do when stuff needs to go live? Check every file for proper permissions?
  3. at some point you will find that the active server acts differently and you will decide to use a "chmod 777" on your active server. Opening a can of worms.

For a correct working website the permissions can be set (and reset) with these 2 commands:

find /var/www/html/mysite -type d -exec chmod 755 {} \;
find /var/www/html/mysite -type f -exec chmod 644 {} \;
| improve this answer | |
  • Not just an answer, a solution! ;-) – Elder Geek Mar 20 '16 at 20:46
  • I was actually looking for what a '.' will do instead of a file or folder name. But you got exactly what I was doing ;) I guess this is a common mistake linux noobs do. Thanks for the hint on correct permissions. – Vivek V Dwivedi Mar 20 '16 at 20:51
  • @VivekVDwivedi you are welcome :-) The 2 commands tend to have a "." instead of a directory and have "sudo" in front of it. And that often messes things up: someone forgot they did a cd / and all of a sudden the whole system is changed. Be careful with chmod. It looks easy and not dangerous but it most certainly is not. – Rinzwind Mar 20 '16 at 20:52

chmod 777 makes a file/folder readable, write-able and executable by everyone.

So essentially on your site folder, you have given everyone permission to write to that folder, so you have reduced security on the folder. Not a good thing on a public web server, but I am guessing this is for development purposes on your local box.

The -R argument also means that it is recursive so the permission change applies to every file in that directory.

| improve this answer | |

The result of your action is full read, write, and execute permissions via chmod 777 on every file in the directory you ran the command in and dur to the -R (recursive) switch every file in every directory under that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.