CHMOD recursively

by Nazly on Monday, 29th September 2008 08:34:58

Time to time I come across this problem when I have to move large portions of directories and files from one location to another. Mostly after extracting from tar archives. The directory/file permissions are often messed up depending on the source I copied them or based on the way I copied/archived them. So I used to use this technique to CHMOD directories and files recursively. Today when I was using this I thought of blogging it for my own future reference. If there is a better way feel free to comment.

CHMOD directories only

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

CHMOD files only

find . -type f -exec chmod 644 {} \;
Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • email
  • LinkedIn
  • PDF
  • Print
  • Reddit

4 comments

I'm sure you have tried chmod -R [directory] ;)

by Kosala on September 29, 2008 at 14:40. #

yes of course. Thats quite basic considering if want to CHMOD both dirs and files. But the case is bit different here since sometimes I only want to CHMOD the directories not the files. In this case I find this option handy

by Nazly on September 29, 2008 at 15:18. #

Thanks! Was searching for this for long. :)

by Grischa on May 31, 2009 at 21:01. #

This is a cool trick.

Thanks.

by Ivan Radisson on June 26, 2009 at 07:51. #

Leave your comment

Required.

Required. Not published.

If you have one.