LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chmod directories recursively (http://www.linuxquestions.org/questions/linux-newbie-8/chmod-directories-recursively-435739/)

mfilippa 04-16-2006 04:45 PM

chmod directories recursively
 
Hey,

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:

Code:

# 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?

Thanks!
Mariano

druuna 04-16-2006 05:23 PM

Hi,

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

Code:

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 !

Thanks!


All times are GMT -5. The time now is 05:14 PM.