How to change permissions for a folder and its subfolders/files in one step
Asked 07 September, 2021
Viewed 2K times
  • 58
Votes

I would like to change the permissions of a folder and all its subfolders and files in one step (command) in Linux.

I have already tried the below command but it works only for the mentioned folder:

chmod 775 /opt/lampp/htdocs

Is there a way to set chmod 755 for /opt/lampp/htdocs and all of its content including subfolders and files?

Also, in the future, if I create a new folder or file inside htdocs, how can the permissions of that automatically be set to 755?

I had a look at this Stack Overflow question too:

How can I set a default 'chmod' in a Linux terminal?

20 Answer