WarpZero RSS WarpZero@Twitter WarpZero@LinkedIn Michael Marth@Facebook Monday, 21-May-2012 01:51:17 EDT
   
warpzero.com

° Home
° News & Updates
° Howto & Knowledge Base
° External Resources
° Contact us
° Search
° Site Validated
° Site Map




Using find, change permissions on files / directories




This document should help provide the necessary information to find specific files / directories and replace the permissions on a mass scale on a linux or unix system.




  1. Replace the parameters in bold with your criteria.
    Note the trailing semi-colon ";" after the slash "\" slash and yes there is a space after the last curly bracket "}"

    find /directory -name \*.log -exec chmod "700" {} \;

  2. Example 1: Search for file types within the /testing directory with an extension of .log and set permission to 600

    find /testing -type f -name \*.log -exec chmod "600" {} \;

    Results are as follows:

    BEFORE
    ls -al /testing/
    -rw-r-----  1 root root    5017 2010-08-10 13:53 access.log
    -rw-rw----  1 root root 1140632 2010-08-10 13:53 errors
    -rw-r-----  1 root root 6950126 2010-08-10 13:53 security.log
    

    AFTER
    ls -al /testing/
    -rw-------  1 root root    5017 2010-08-10 13:53 access.log
    -rw-rw----  1 root root 1140632 2010-08-10 13:53 errors
    -rw-------  1 root root 6950126 2010-08-10 13:53 mod_gzip.log
    


  3. Example 2: Search for directory types within the /testing directory with a name of bin and set permission to 700

    find /testing -type d -name bin -exec chmod "700" {} \;
Linux Counter
Apache
IBM Canada
Cisco Systems
RedHat
Linux
 
 Published: Wednesday, 10-Nov-2010 05:16:05 EST