Recursive Chmod Tricks

by damonp on June 27, 2007

in Snippets,SysAdmin

Recursively chmod only directories

find . -type d -exec chmod 755 {} \;

Similarly, recursively set the execute bit on every directory

chmod -R a+X *

The +X flag sets the execute bit on directories only

Recursively chmod only files

find . -type f -exec chmod 644 {} \;

Recursively chmod only PHP files (with extension .php)

find . -type f -name '*.php' -exec chmod 644 {} \;

Popularity: 52%

Most Popular Posts

Damon Parker is a freelance sysadmin and web developer in Texas. He specializes in server setup, server security and high performance server configurations. Need help setting up a web server or getting a server back online after a crash or hack? Email Damon

{ 8 comments… read them below or add one }

ing_uu_mm December 18, 2009 at 1:28 pm

saved my day. thanks a lot

Reply

girl_on_fly December 23, 2009 at 7:07 am

Awesome! Thank you!

Reply

me March 15, 2010 at 11:22 pm

Thanks!

Reply

soda June 28, 2010 at 10:43 pm

Thx man, for your recursive chmod tricks!

Reply

Rick August 3, 2010 at 11:49 pm

Rock on, Damon. Very clean, clear and helpful.

Reply

a_developer August 13, 2010 at 11:38 am

Fabulous!
Just what I need.

Thanks.

Reply

anne September 2, 2010 at 10:25 pm

saved my day too. thanks a very lot

Reply

Bob October 30, 2010 at 5:05 pm

Thank You!! Saved my day aswell. :)

Reply

Leave a Comment

{ 3 trackbacks }

Previous post:

Next post: