What syntax for global 'chown' fix?
Dan Dubovik
dandubo at gmail.com
Tue Jun 8 12:53:39 MST 2010
For the record, I'm with Dale here. Generally speaking, running a chown /
chmod against an entire system is bad. There are system files that have
setuid / setgid set, and for good reason (/bin/su comes to mind). There
could be uses for specific directories however, and with that in mind:
>From the find man page:
-P Never follow symbolic links. This is the default behaviour.
When find examines or prints information a file, and the file is a
symbolic link, the information used shall be taken from the properties of
the symbolic link itself.
So to shorten Kaia's command, just add -P to it, and it will ignore
symlinks. Mind you, this is being explicit in the command, as the default
is to not follow symlinks. If you want it to follow symlinks, use the -L
switch.
This would modify the command to:
find -P [dir] -exec chown user:group {} \;
On Tue, Jun 8, 2010 at 11:57 AM, <joe at actionline.com> wrote:
>
> 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 {} \;
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20100608/4971dbc8/attachment.html>
More information about the PLUG-discuss
mailing list