[NBLUG/talk] chmod question

troy fryman at sonic.net
Thu Oct 9 11:42:00 PDT 2003


On Thu, Oct 09, 2003 at 02:31:46PM -0400, Bob Blick wrote:
> How can I get chmod to only affect files, not directories? Like if root
> has done:
> chmod -R +x * to my stuff instead of chmod -R +X *
> 
> and now _I_ need to fix my own stuff. I have many many levels of
> directories and files and I am not root.
> 
> I can't do this:
> chmod -R -x *
> chmod -R +X *

'find' is a great tool to have in your box.
find . -type f -exec chmod -x {} \;

That tells find to start in the current dir (.) and run chmod on all
regular files ( -type f)

To turn on execute for dirs:
find . -type d -exec chmod +x {} \;

I suggest looking over the manpage for find, or checking out the find
page in a book like O'Reilly's _Unix in a Nutshell_

Also, double check those arguments to chmod.  I'm used to using the
octal modes, and don't know chmod's flags.

-troy





More information about the talk mailing list