Linux recursive chmod only on sub-directories

Go To


I'm on linux, and I have a directory with numerous sub-directories and items inside them. I want to run a recursive chmod on all directories and sub-directories but NONE of the files inside those directories.

chmod -R 777 {folder}

Is there a flag I can add to the chmod command to make the chmod only apply to sub-directories?

2012-04-03 21:46
by Sean


Off the top of my head:

find {folder} -type d -print0 | xargs -0 chmod 777
2012-04-03 21:49
by Philip Kendall


find {folder} -type d -print0 | xargs -0 chmod 777

2012-04-03 21:51
by quodlibetor



find {folder} -type d -exec chmod 777 {} \;

2012-04-03 21:54
by Darren Dempsey
In general, find | xargs will be more efficient than find -exec as xargs will batch together calls to , whereas find -exec will call once for every result. Obviously though there are some situations in which you want a separate call for each result - Philip Kendall 2012-04-03 22:10


Straight from the man pages:

And also corroborated here:

use the following format or a derivative thereof chmod -R u=rwX,go=rwX {folder}

Hope that helps!

2014-10-16 05:50
by Jared Scott