This function needs to be run in STRQSH.
In order to change the owner of all files and directories recursively run the following command:
for eachFile in $(find /directoryToChangeOwner -name '*');
do system "CHGOWN OBJ('"$eachFile"') NEWOWN(userProfile)";done
Note: Replace values in parenthesis with appropriate values.
Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.
6/23/08 Recursively changing ownership on an IFS directory and all the files stored within it
Labels:
Authorities,
Physical files
Subscribe to:
Post Comments (Atom)
4 comments:
Or you can run this on a command line:
CHGOWN OBJ('directoryToChangeOwner/*') NEWOWN(newOwner)
Thank you for your feedback concerning this blog entry. If we were looking at simply changing the ownership of all files and directories within a single directory then your suggestion is more succinct and should actually finish the process faster. However, using the CHGOWN command with the asterisk in the way you suggest would change, for example, "/home/chris/*" but it would not change the content of any directories within "/home/chris". The function we have suggested above would change the ownership of "/home/chris/*/*/*/*/*" recursively, regardless of the number of levels of directory structure you have on your file system.
Or, from QSH, issue "chown -R newOwner directoryToChangeOwner".
Post a Comment