chmod 777: what it means and when to use it
chmod 777 gives everyone full permission: any user on the system can read, change and execute the file.
777
rwxrwxrwx
| Who | Digit | Read | Write | Execute |
|---|---|---|---|---|
| Owner | 7 |
Yes | Yes | Yes |
| Group | 7 |
Yes | Yes | Yes |
| Everyone else | 7 |
Yes | Yes | Yes |
How chmod 777 works
Every digit is 7, which is read plus write plus execute, 4 + 2 + 1, for the owner, the group and everyone else alike.
It is almost always the wrong answer. 777 usually appears when an upload folder or a cache directory throws a permission error and the quickest fix is to open everything. The error goes away, but any other user or process on the server can now rewrite your files, including code that will run later.
The better fix is to make the user that needs access the owner, often the web server's user, with chown, and keep the folder at 755, or 775 if a group needs to write to it.
Where 777 belongs
- Short lived scratch folders on a machine only you use
- Confirming that a problem is about permissions, then setting it back
The command
Both of these set exactly the same permissions. The number is shorter; the letters are easier to read back later.
chmod 777 filename
chmod u=rwx,g=rwx,o=rwx filename
Never leave 777 on anything a web server serves or that other users can reach. Many hosting providers block it outright.