CHMOD Folder and Files recursively but with different values

1

Is there a way to recursively change the access rights of a specific folder to 755 and files to 644 Without using the find function and having sub-directories in that folder (don't want to change those) ?

Currently I'm using chmod 755 -r folderName/

using find I think its something like that :

find /specific_folder/ -type f -print | xargs chmod 644

Tarek

Posted 2011-06-29T11:23:17.760

Reputation: 123

Answers

3

You can do it this way:

chmod -R a=rX,u+w folderName

For CentOs the command is:

chmod -R a=rx,u+w folderName

But it will rewrite subdirectory permissions. As the consequence: you cannot do what you want with just chmod.

akond

Posted 2011-06-29T11:23:17.760

Reputation: 236

will that only work on files ? what about sub-directories .. i dont want to change their permissions – Tarek – 2011-06-29T11:30:33.227

yes, it does work for sub-directories as well. – None – 2011-06-29T11:32:42.160

just tried that and it doesn't work – Tarek – 2011-06-29T11:43:24.820

You mean doesn't work at all or what? – None – 2011-06-29T11:45:20.450

yes it doesn't work at all – Tarek – 2011-06-29T11:52:23.437

@Tarek let us continue this discussion in chat

– None – 2011-06-29T11:54:11.877