What will be result of chmod -R 777

67,609

Solution 1

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 {} \;

Solution 2

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.

Share:
67,609

Related videos on Youtube

Vivek V Dwivedi
Author by

Vivek V Dwivedi

Human! Coder! Problem Solver! Pretentious Nomad!

Updated on September 18, 2022

Comments

  • Vivek V Dwivedi
    Vivek V Dwivedi over 1 year

    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.

  • Elder Geek
    Elder Geek about 8 years
    Not just an answer, a solution! ;-)
  • Vivek V Dwivedi
    Vivek V Dwivedi about 8 years
    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.
  • Rinzwind
    Rinzwind about 8 years
    @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.