'Why do the execute bits need to be set?
I have a simple python script that is writing data to a file in a log folder. The script is in /var/lib/cgi-bin and the log folder is in /var/lib/cgi-bin/logs. As the files in cgi-bin are executed by Apache or by me from the command line, the execute bits are set for both cgi-bin and files in cgi-bin.
However, when I try setting 666 on the cgi-bin/logs folder, the python script fails when I attempt to open a new log file to store data. If I set the permissions on cgi-bin/logs to 776, the script executes both from the command line and when a browser executes a file in cgi-bin.
Why does a folder that will only contain data need the execute bit set? Is it due to being inside a folder that must have the execute bits set?
Solution 1:[1]
I was thinking that a folder's permissions were inherited by the folder's contents which is incorrect.
Tkausl pointed out that execute permission on a folder doesn't mean the same thing that execute permission means on a file. For a folder, execute permission means the folder's contents may be viewed by the owner, group and/or all.
Linux uses a specific command, setfacl, to handle default file permissions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Michael |
