I was adjusting the permissions when setting up some WordPress themes, and ran chmod 664 -R theme-dir/*
It worked fine on the files in the root of the directory, but all the files in subdirectories now read like this when I ls -l
:
?--------- ? ? ? ? ? core_functions.php
?--------- ? ? ? ? ? css
?--------- ? ? ? ? ? custom_functions.php
?--------- ? ? ? ? ? images
?--------- ? ? ? ? ? import_settings.php
?--------- ? ? ? ? ? js
?--------- ? ? ? ? ? options_trim.php
?--------- ? ? ? ? ? page_templates
?--------- ? ? ? ? ? post_thumbnails_trim.php
?---------+ ? ? ? ? ? shortcodes
I can't cd to any of the subdirectories, and I also can't delete them. I've never seen anything like this, anybody ever run into something similar?
Best Answer
Accessing the contents (or more specifically file metadata except for filename) of a directory requires that the directory have the execute bit set.
Your recursive chmod removed that permission, so you lost that access. If you are using the
-R
option ofchmod
is better to avoid using the numeric version of the permissions, and instead run (using your desired state as an example)chmod -R ug=rwX,o=rX
. The capital X there means set the X bit only on directories or files that have at least onex
set. Also you might want to use 644 (u=rwX,go=rX
) unless you really need group users to write.