Change permissions on a directory and all subdirectories in Linux

About Changing Permissions on a Directory and All Subdirectories

You may sometimes run into a situation where you want to change the permission on a directory and all other subdirectories beneath it. This might be the situation after restoring a WordPress site from one hosted server to another.

The problem with the Linux chmod command is that it will change permissions of both files AND directories.

Instead, use the following command to change the permissions on a directory and all the subdirectories to 755 (drwxr-xr-x) beneath it:

find /opt/lampp/htdocs -type d -exec chmod 755 {} \;

Should you wish to only change the permissions of files to 644 (-rw-r--r--), use the following command:

find /opt/lampp/htdocs -type f -exec chmod 644 {} \;


Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top