Recursively chmod only directories or files

July 22, 2008

Ever come across the problem of needing to chmod a directory and its many, many, sub-directories, but you don’t want to touch any of the files? Maybe it’s the exact opposite, or you need to recursively change the permissions on only files with a specific extension. Well I had a similar problem with one of the RainSoft Letters server backups.

Luckily, I came across a post on movabletripe that dealt with the problem, as well as having some additional find snippets in the comments. The original article is here: Recursively chmod directories only.

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

  • This will “find” all directories, starting at “.“, and chmod them to 755.

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

  • This snippet does the opposite and finds only files. The difference (beside the file permissions) is the “-type f“, “f” specifies files and “d” directories.

If you check the comments, you’ll find a few additional snippets:

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

  • This lets you “find” files (”-type f“) with a specific extension (”-name '*.htm*'“) and chmod them with your desired permission (”-exec chmod 644 {}“).

chmod -R o+rX

  • This snippet will recursively chmod “other” (”o“) permissions with read/eXecutable (”+rX“), and the capital X ensures that directories and files set (user/group permissions) to executable will be properly modified, while ignoring regular (non-executable) files.

Entry Filed under: Administration, Linux. Tags: , , , , , , , .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Top Posts

Recent Posts

Archives

Feeds

Category Cloud

A and B Marketing Administration Atlantic Water Products Clean Water Specialists Components Delaware Discovery Marketing and Distributing Eastern Shore Water Georgia Joomla Letters Linux Maryland Merequest Marketing and Distributing Miami Valley Water RainSoft New Jersey New York Pure Water Consultants RainSoft RainSoft Of Birmingham RainSoft Of Indianapolis RainSoft Of London RainSoft Of NE Iowa RainSoft Of Ottawa RainSoft Of The Southland Superior Water Conditioners Tri State Water Tri State Water Treatment Uncategorized

RainSoft Photos on Flickr

RainSoft Phoenix Luncheon

RainSoft Seminar Break

RainSoft Seminar Break

More Photos

Blogroll

RainSoft

RainSoft Dealers

RSS Propeller Tag: rainsoft

RSS RainSoft Letters Feed

Pages

 

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

Meta