I'm trying to cleanup permissions on an Apache web server. I'm finding lots of files with the execute bit that don't customarily have it (or should not have it):
$ sudo find /var/www/html -executable -type f | grep '.png'
How can I set the execute bit for regular files that customarily have it (like programs, PHP pages and Bash scripts); and remove it from regular files that customarily don't have it (like TXT, PNG, JPG and ZIP files)?
I feel like
find with an
chmod should come into play somewhere. I also expect the selection mechanism will take into account shebangs and other magic headers; and not just rely on an [potentially incorrect] execute bit or a [potentially missing] extension. But my searching is not landing on the right answer. Cf., How can I find only the executable files under a certain directory in Linux? and Find executable files recursively.