• Home
  • Services
  • Contact Us
  • Support
  • Techie Stuff
  • Downloads
Recursively changing file and directory permissions the elegant way on *NIX environments 25/02/2011
0 Comments
 
Something I've needed to do continuously is change permissions on directories or files only recursively on a linux / unix box.  I'm sure just about every sysadmin has needed to do this sometime in their lives.  Well, the most elegant way I could think of is to do the following:

For directories only:
find /location -type d -exec chmod 775 {} \;
The above example does the following:
  • Finds all directories in the location specified (-type d)
  • Executes "chmod 775" on all directories found leaving files untouched
  • Permissions of 775 are RWX for owner, RWX for owner's group and RX for everyone else
For files only:
find /location -type f -exec chmod 664 {} \;
The above example does the following:
  • Finds all files in the location specified (-type f)
  • Executes "chmod 664" on all files found leaving directories untouched
  • Permissions of 664 are RW for the owner, RW for the owner's group and R for everyone else.
Have fun!
 


Comments


Your comment will be posted after it is approved.


Leave a Reply

    Author

    Alan Johnson is the proprietor of OKES IT Consulting Services.  Having 15+ years technical experience in the IT industry positions OKES IT Consulting Services in a very good position to cover all aspects of IT infrastructure from desktops to servers to networks and everything in between, and beyond!

    Archives

    September 2011
    May 2011
    March 2011
    February 2011
    December 2010

    Categories

    All

    RSS Feed


Content Copyright (C) OKES IT Consulting Services. All rights reserved. Photo used under Creative Commons from Claus Rebler