On Tue, Jun 8, 2010 at 12:53 PM, Dan Dubovik wrote: > 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, 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@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 {} \; >> > Yes, I, too, have worked with the regex command line cowboys, ("Opps was that supposed to be a backtick?")? I would suggest a nice: tar -cvzf /tmp/safetynet-file.tgz {$filespectree} You do of course have a nice automated /tmp directory cleaner on your nix of choice? If not: rm /tmp/safetynet* And also, since I like to remember things I use, so I don't have constantly recreate the wheel, why not put it all in a standard bin as a script? -- Office: (480)307-8707 AT&T: (503)754-4452