|
|
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.
- 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" {} \;
- 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
- 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" {} \;
|
|
|