I uploaded some themes to my wordpress install for my blog recently. What I found was that the wordpress theme failed to read the stylesheet.css. This was frustrating and then I thought about the error. Read. File permissions. Linux. So I SSH’d in and found a very telltale sign something was wrong.
aburke ~/domains/networkinferno.net/html/wp-content/themes/parabola$ ls style.css -l ---------- 1 aburke aburke 48497 Oct 12 15:59 style.css
So lets change our files for this WordPress theme to what is deemed to be the industry standard.
- Change all the files to 644 (-rw-r–r–)
- Change all the directories to 755 (-rwxr-xr-x):
find ./parabola -type f -exec chmod 644 {}
Time to check our style.css file.
aburke ~/domains/networkinferno.net/html/wp-content/themes/parabola$ ls style.css -l -rw-r--r-- 1 aburke aburke 48497 Oct 12 15:59 style.css
Now to do this to the folders under the theme directory.
find ./parabola -type d -exec chmod 755 {} +
{} is replaced by the file path upon execution.
To issue this to all folders and sub-folders within my theme we use the -R switch. This switch means the change is Recursive. The command would look like the following.
chmod -R chmod -R 644 -type f -R ./parabola chmod -R 755 -type d -R ./parabola
Some tips
Something to remember. If you have a very large amount of files it may be worth considering other methods of executing this function. The chmod command will spawn a process for every file and folder it is run against. If the recursed directory has 20,000 files then CPU and Storage may take a hit whilst the action occurs.
Might be worth going over the File Permissions section of the Hardening WordPress guide (http://codex.wordpress.org/Hardening_WordPress)
Great. Thanks for the link DXPetti.
Very good guide on hardening WordPress installations.