-   Linux - Newbie (
-   -   chmod directories recursively (

mfilippa 04-16-2006 04:45 PM

chmod directories recursively

I have thousands of files and directories on my samba server. I changed all permissions (chmod) to <rwx> for owner and <r> for the rest. However, I want directories to be accessible to the rest of the users, for which I need to do:


# chmod -R u=rwx,go=r *    >> for files
# chmod -R u=rwx,go=rx *  >> for directories

I could not find any way to chmod files and directories differently. One-by-one is not an option. Any ideas on how to do this?

If there is no way around, what is the harm of setting <x> for any file in a samba server for any user? will it execute if called from windoze?


druuna 04-16-2006 05:23 PM


You could use find:

For files:
find . -type f -exe chmod u=rwx,go=r {} \;

For dirs:
find . -type d -exe chmod u=rwx,go=rx {} \;

This is done recursively from the dir you are in.

Hope this helps.

acid_kewpie 04-16-2006 05:25 PM


find -type f /var/blah/dir/ -exec chmod 744 {} \;
find -type d /var/blah/dir/ -exec chmod 755 {} \;

mfilippa 04-17-2006 08:24 PM

That was easy !


All times are GMT -5. The time now is 11:23 AM.