[NTLUG:Discuss] fixing/managing file rights - samba
Greg Edwards
greg at nas-inet.com
Sat May 20 03:46:45 CDT 2006
Richard Geoffrion wrote:
>
> If you ever find yourself in the need to do some surgical file
> maintenance, you might trying using the syntax...
>
> find (insert your options) | while read X ; \
> do (Insert your command here) "$X" ; done
>
> My commands turned out to be,
>
> # find . -type d | while read X ; do chmod 2770 "$X" ; done
> # find . -type f | while read X ; do chmod 2660 "$X" ; done
>
> Note: I put quote marks around $X so that I could encompass those space
> filled directory names.
>
> Another use I've put this to...
>
> #Set a new owner to be the owner of any unowned files in this directory
> find . -type f -nouser | while read X; do chown bob "$X" ; done
>
>
I like to use the -exec option with find for these kinds of commands.
# find . -type d -exec chmod 2770 "{}" ";"
# find . -type f -exec chmod 2660 "{}" ";"
The find exec processing will take care of all of the oddball filename
issues for you. This will run a little faster than piping to a shell for
processing. And since we are using a real OS you can put them in the
background and go about your business elsewhere ;\
--
Greg Edwards
More information about the Discuss
mailing list