Changing only directory permissions on UNIX recursively

One of those technical buggers that I couldn’t figure out, is how to make your command prompt run through a directory and change the permissions (chmod) for only directories in it. Then, just to top it off, do it recursively:

find /dir/to/chmod/all/dirs -type d -exec chmod -R 755 {} \;

That helps us, hope it helps others!  Many thanks to linox.be for the tip!

Nonprofit news, strategy, and tactics sent straight to your inbox
Sign up for the Soapbox Engage newsletter




This entry was posted on Thursday, October 5th, 2006 at 7:56 am and is filed under quick tips. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses to “Changing only directory permissions on UNIX recursively”

  1. ben says:

    It seems that this grabs ALL files as well. I got it to work by removing the -R option from chmod. I’m assuming this is because the find -type d command is grabbing all dirs (well, it spits out all the dirs when I run find /path -type d).

    Thanks. Neat trick.

    Ben

  2. Fred says:

    The “-R” isn’t mentioned on linox.be ;)

  3. ARVasko says:

    The option -R is useless… cause you already have all the directories when you use “find -type d”. =)

Leave a Reply

You must be logged in to post a comment.