• 1
name Punditsdkoslkdosdkoskdo

How do I set chmod for a folder and all of its subfolders and files?

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?

This works, but only for this folder:

chmod 775 /opt/lampp/htdocs

The other answers are correct, in that chmod -R 755 will set this as permissions to all files and folders in the tree. But why on earth would you want to? It might make sense for the directories, but why set the execute bit on all the files?

I suspect what you really want to do is set the directories to 755 and either leave the files alone or set them to 644. For this, you can use the find command. For example:

To change all the directories to 755 (drwxr-xr-x):

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

To change all the files to 644 (-rw-r--r--):

find /opt/lampp/htdocs -type f -exec chmod 644 {} ;
  • 0
Reply Report


Related Questions

Trending Tags