I've just upgraded my development machine and have moved over a website I was working on. However, the permissions don't seem to have moved over properly. The dev machine is a Linux machine which runs Apache, where all the folders and sub-folders were set to 755 and all the files and files within all sub folders were set to 644.

Instead of me having to run the commands:

chmod 755

chmod 644

Is there a quicker way of doing this without having to do each and every file and folder individually?

2 Answers 2


for files:

find -type f -exec chmod 0644 {} \; 

for dirs:

find -type d -exec chmod 0755 {} \; 

If the problem is that the files are not readable by everyone:

chmod -R a+rX /var/www

(Note the capital X, meaning that only directories and files that are executable by at least one user are made executable).

If the problem is that the files are writable by users other than the owner:

chmod -R go-w /var/www

If the problem is that files are executable, and you don't want to have any executable file: chmod -R a-x won't do it, because directories need to remain executable (the execution permission for a directory controls whether you can access files inside it). You need to be more discriminating. In zsh, you can run chmod a-x /var/www/**/*(.), using the **/ syntax to recurse into subdirectories and the . glob qualifier to match only regular files. In any shell, you can use find:

find /var/www -type f -exec chmod a-x {} +

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .