# FreeBSD 12.1-RELEASE (Does anyone know how to mass set folder/files to specific chmod settings) ?



## StreetDancer (Jul 20, 2020)

For instance; CMS Joomla is recommended here on this thread https://forum.joomla.org/viewtopic.php?t=933652 


> find -type d -exec chmod 755 {} \;
> find -type f -exec chmod 644 {} \;
> This sets recursively the folder permissions to 755 (770 is wrong!) and files to "644"



What is the FreeBSD way of achieving the same results?


----------



## Datapanic (Jul 20, 2020)

FreeBSD's `find` has a different syntax.  Regardless, I would never run those commands on \ (root)!


----------



## richardtoohey2 (Jul 20, 2020)

I think you have to give find the directory to start from.

e.g.

```
find . -type d -exec chmod 755 {} \;
```

But I've not tested it.

As Datapanic says - use with caution - set up a test directory with sub-directories on a test machine/environment and try it there first.


----------



## StreetDancer (Jul 20, 2020)

richardtoohey2 said:


> I think you have to give find the directory to start from.
> 
> e.g.
> 
> ...


richardtoohey2,

What command would you use? And do you have a working example of how you would set a folder and it's inherent folders x chmod ### & chmod files x ### ? 

Thanks!


----------



## StreetDancer (Jul 20, 2020)

Datapanic said:


> FreeBSD's `find` has a different syntax.  Regardless, I would never run those commands on \ (root)!


Datapanic,

That makes sense! I will use with caution!


----------



## richardtoohey2 (Jul 20, 2020)

I'd use the command I pasted if you want to use that model - did you see the extra "." in what I put in?  That means the current directory.  So from the current directory downwards.

You can use the commands you found if you want to.  You just need to tweak for FreeBSD.

So I'd recommend setting up something like

test1

with sub-directories test2, test3, test4.  And maybe some child sub-directories inside those like child1, child2 or whatever.

Then cd test1 and run the find commands with "." and see what they do - does it match the Joomla advice?

And note you may want to run the commands as root, but not from the root "/" directory.


----------



## jmos (Jul 20, 2020)

I'm using for this almost the same:
`find /path/to/dir/ \( -type d -exec chmod 755 {} + \) -o \( -type f -exec chmod 644 {} + \)`


----------



## StreetDancer (Jul 20, 2020)

richardtoohey2 said:


> I'd use the command I pasted if you want to use that model - did you see the extra "." in what I put in?  That means the current directory.  So from the current directory downwards.
> 
> You can use the commands you found if you want to.  You just need to tweak for FreeBSD.
> 
> ...


richardtoohey2,

Thank you for the detailed explanation. That helped me understand a whole lot better.


----------

