PDA

View Full Version : Changing permisions


RedFedora
12th November 2004, 01:20 PM
I have an odd problem that I'm hoping you can help me with.
I have a large directory tree filled with thousands of files and sub-directories.
What I would like to do is make all of the files in this tree read-writeable, but
non-executable. I would like to make the directories executable (enterable?)
as well as readable.
Normally, I would use chmod with the recursive flag for this, but since the directories
and files should have different permissions, I don't want to do it that way.

Can someone suggest a way to use chmod and ... I dunno, find?, to set different
permissions on directories and files in a tree?

crackers
12th November 2004, 07:20 PM
Yup, like this:

# find dirname -type d -exec chmod a+x {} \;
# find dirname -type f -exec chmod a+rw {} \;

Note that this shouldn't change the execute bits on any executable files in the tree because you're "adding" permissions (the "+").

RedFedora
13th November 2004, 03:17 AM

Crackers, thanks a lot. That worked perfectly. My stumbling block before was not knowing how to use the find "type" argument, I think.

crackers
13th November 2004, 06:08 AM
Heck, I didn't even figure out how to use the "-exec" flag properly until this year... :o