What’s wrong with these file permissions

permissions

This is an embarassing question, but I can't seem to figure out the proper file permissions for my server. I want to create a directory in my public_html folder that includes read/write access for everyone so that I can easily create files there via php scripts executed when a user loads a web page.

Here's the current permissions showing:

drw-rw-rw- 2 root www-data    4096 Aug 27 19:38 TEMPFILES

When I execute a php script as a random user who is not root and not in the www-data group, I get an error "Permission denied" when trying to write a file to TEMPFILES. Why is that?

Best Answer

chmod a+x TEMPFILES

As directories must have the eXecute bit because reasons[1]. (You may also want the sticky bit like is set on for example /tmp.)

[1] "Note that read permission for a directory and execute permission for a directory mean different things. Read permission lets us read the directory, obtaining a list of all the filenames in the directory. Execute permission lets us pass through the directory when it is a component of a pathname that we are trying to access." -- Stevens, "APUE" (first edition), chapter 4, section 5.

Related Question