Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to change permissions on a tree on Centos 4 to add execute permissions for all directories recursively from a directory. If I use normal chmod, files other than directories are also modified:

chmod -R o+x /my/path/here

How can I only affect directories?

share|improve this question
add comment

2 Answers

up vote 16 down vote accepted

Run find on -type d (directories) with the -exec primary to perform the chmod only on folders:

find /your/path/here -type d -exec chmod o+x {} \;

To be sure it only performs it on desired objects, you can run just find /your/path/here -type d first; it will simply print out the directories it finds.

share|improve this answer
add comment

See Command line examples - chmod in the Wikipedia.

chmod -R a-x+X directory    remove the execute permission on all files in 
                            a directory tree, while allowing for directory browsing.

As added by Daniel: this should work in your case:

chmod -R o+X directory
share|improve this answer
    
This would affect the current permissions of files within directories. –  scriptmonster Jul 29 '12 at 15:27
    
@scriptmonster the line quoted is wrong for this case, but chmod -R o+X directory should work for the OP. –  Daniel Beck Jul 29 '12 at 15:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.