What syntax for global 'chown' fix?

joe at actionline.com joe at actionline.com
Tue Jun 8 11:57:13 MST 2010


Thanks Dale, Kaia, and Eric ...

Sincerely appreciate all of your answers. Each one helped.

I fully realize that entirely too often, I have no idea what I am doing;
but I just blindly muddle along anyway and somehow, by the grace of God
and the guidance of so many excellent plug friends, I manage to sort
things out and happily survive. ;)

In this case, I learned a bit more from each answer, some of which I
understand, and some of which I still do not understand. However, I got
the result that I needed. I just test various commands on a small sample
and once I eventually get something to work, I apply it further.

Joe


> I originally wrote:
>> While the example commands below work to change permission for either a
>> complete system or for a complete directory and all sub-directories,
>> what would the syntax be for a similar command to 'chown' (change the
>> owner) globally or for a designated directory and and the files and
>> subdirectories below it?
>>
>> find . -type f -print0 | xargs -0 chmod 644
>> find . -type d -print0 | xargs -0 chmod 755
>>
>> find dir -type f -print0 | xargs -0 chmod 644
>> find dir -type d -print0 | xargs -0 chmod 744

Dale wrote:
> Joe, before answering your question, I feel the need to warn you.
>
> If you understood what the above commands do, the answer would be obvious
> and you wouldn't have asked the question.  Further, IMHO, unless you know
> what each part of the above commands do, you shouldn't use them.  Each
> line has three commands, each of which is readily understandable with
> some effort.
>
> (BTW, none of the above commands change permissions for a complete system.
> They only do it recursively for files in a directory or for a directory
> and its subdirectories.)
>
> To change the owner and group for a directory and recursively to its
> files and subdirectories, do:
>
> (1)	chown -R owner:group dir
>
> To change just the owner:
>
> (2)	chown -R owner dir
>
> To change just the group:
>
> (3)	chown -R :group dir
>
> An alternative way (just less efficient) to accomplish (1) is:
>
> (4)	find dir -print0 | xargs -0 chown owner:group
>
> -Dale

===== Previous replies:
A: Eric wrote: to globally change owner:
find dir -type f -exec chmod user:group {} \;
find dir -type d -exec chmod user:group {} \;

(J: I discovered that 'chmod' in the Eric's example
should apparently have been 'chown' ... I think.)

A: Kaia.Taylor at schwab.com -- To avoid any surprises with links,
if there are any, do this first:
find [dir] -type l | more
Then:
find [dir] -exec chown user:group {} \;





More information about the PLUG-discuss mailing list