RE: [SLUG] recursively change file permissions not directories

2003-08-14 Thread Tony Green
On Tue, 2003-08-12 at 17:27, Rowling, Jill wrote:
 The sequence find . -exec seems safe enough though.
 I suspect it just uses the inode numbers rather than the file name or
 something (but beware this is on Solaris ;)

Very true if you're not working with a large list.

Doing it this way, you'll have a command spawned for each file find
finds, where as xargs will fit as many files into one command as
possible.

You won't notice a difference on a small list, but on a big one it takes
much more time/resources to use the -exec option

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


RE: [SLUG] recursively change file permissions not directories

2003-08-14 Thread Rowling, Jill
The sequence find . -exec seems safe enough though.
I suspect it just uses the inode numbers rather than the file name or
something (but beware this is on Solaris ;)
bash-2.05$ find thingy -type f -exec file {} \;
thingy/one/this:empty file
thingy/two/; file thingy:   empty file
thingy/three/that:  empty file
bash-2.05$ ls -lR thingy
thingy:
total 6
drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 one
drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 three
drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 two

thingy/one:
total 0
-rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 this

thingy/three:
total 0
-rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 that

thingy/two:
total 0
-rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 ; file thingy
bash-2.05$

- Jill
-- 
Jill Rowling, System Administrator
Eng. Systems Dept, Aristocrat Technologies Australia
Level 2, 55 Mentmore Ave Rosebery NSW 2018
Phone: (02) 9697-4484 Fax: (02) 9663-1412 Email: [EMAIL PROTECTED]


-Original Message-
From: Andrew McNaughton [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 12 August 2003 5:08 PM
To: Norman Gaywood
Cc: [EMAIL PROTECTED]; Ram Smith
Subject: Re: [SLUG] recursively change file permissions not directories


On Tue, 12 Aug 2003, Norman Gaywood wrote:

 Date: Tue, 12 Aug 2003 12:50:01 +1000
 From: Norman Gaywood [EMAIL PROTECTED]
 To: Ram Smith [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [SLUG] recursively change file permissions not 
 directories

 On Tue, Aug 12, 2003 at 11:32:06AM +1000, Ram Smith wrote:
  I have a shared directory structure where alot of the files in each 
  directory have permisions of 644 I wanting to change it so that the 
  files are chmod 664 letting all users in the group read and write to 
  the data. without nuking the permissions on the directories along 
  with the files.

 The way to do this properly, as others are showing, is with a:

   find . -type f | xargs chmod 644

This is not doing things properly and is highly dangerous. eg:

[EMAIL PROTECTED]  touch ;chmod u+sx

[ some time later ]

[EMAIL PROTECTED] find . -type f | xargs chmod 644

Andrew McNaughton




--

No added Sugar.  Not tested on animals.  May contain traces of Nuts.  If
irritation occurs, discontinue use.

---
Andrew McNaughton   In Sydney
Working on a Product Recommender System
[EMAIL PROTECTED]
Mobile: +61 422 753 792 http://staff.scoop.co.nz/andrew/cv.doc



-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

--
IMPORTANT NOTICES
This email (including any documents referred to in, or attached, to this
email) may contain information that is personal, confidential or the subject
of copyright or other proprietary rights in favour of Aristocrat, its
affiliates or third parties. This email is intended only for the named
addressee. Any privacy, confidence, copyright or other proprietary rights in
favour of Aristocrat, its affiliates or third parties, is not lost because
this email was sent to you by mistake.

If you received this email by mistake you should: (i) not copy, disclose,
distribute or otherwise use it, or its contents, without the consent of
Aristocrat or the owner of the relevant rights; (ii) let us know of the
mistake by reply email or by telephone (+61 2 9413 6300); and (iii) delete
it from your system and destroy all copies.

Any personal information contained in this email must be handled in
accordance with applicable privacy laws.

Electronic and internet communications can be interfered with or affected by
viruses and other defects. As a result, such communications may not be
successfully received or, if received, may cause interference with the
integrity of receiving, processing or related systems (including hardware,
software and data or information on, or using, that hardware or software).
Aristocrat gives no assurances in relation to these matters.

If you have any doubts about the veracity or integrity of any electronic
communication we appear to have sent you, please call +61 2 9413 6300 for
clarification.
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


RE: [SLUG] recursively change file permissions not directories

2003-08-14 Thread Rowling, Jill
Hehehe I have yet to find that limit here (E250s and V880).
But on a big list like searching the entire SMB-shared systems for the odd
mad Windows virus file (I won't go into HOW that happened), I just set it
going and do something else.
The find seems to sit on one CPU whereas the other CPUs in the box seem to
take the other jobs. I guess that's what SMP hardware can do for you: it
lets you run sloppy software and get away with it!

Regards,

Jill.



-Original Message-
From: Tony Green [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 12 August 2003 5:36 PM
To: Rowling, Jill
Cc: [EMAIL PROTECTED]
Subject: RE: [SLUG] recursively change file permissions not directories


On Tue, 2003-08-12 at 17:27, Rowling, Jill wrote:
 The sequence find . -exec seems safe enough though.
 I suspect it just uses the inode numbers rather than the file name or 
 something (but beware this is on Solaris ;)

Very true if you're not working with a large list.

Doing it this way, you'll have a command spawned for each file find finds,
where as xargs will fit as many files into one command as possible.

You won't notice a difference on a small list, but on a big one it takes
much more time/resources to use the -exec option

--
IMPORTANT NOTICES
This email (including any documents referred to in, or attached, to this
email) may contain information that is personal, confidential or the subject
of copyright or other proprietary rights in favour of Aristocrat, its
affiliates or third parties. This email is intended only for the named
addressee. Any privacy, confidence, copyright or other proprietary rights in
favour of Aristocrat, its affiliates or third parties, is not lost because
this email was sent to you by mistake.

If you received this email by mistake you should: (i) not copy, disclose,
distribute or otherwise use it, or its contents, without the consent of
Aristocrat or the owner of the relevant rights; (ii) let us know of the
mistake by reply email or by telephone (+61 2 9413 6300); and (iii) delete
it from your system and destroy all copies.

Any personal information contained in this email must be handled in
accordance with applicable privacy laws.

Electronic and internet communications can be interfered with or affected by
viruses and other defects. As a result, such communications may not be
successfully received or, if received, may cause interference with the
integrity of receiving, processing or related systems (including hardware,
software and data or information on, or using, that hardware or software).
Aristocrat gives no assurances in relation to these matters.

If you have any doubts about the veracity or integrity of any electronic
communication we appear to have sent you, please call +61 2 9413 6300 for
clarification.
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] recursively change file permissions not directories

2003-08-14 Thread mlh

To use xargs safely you use the -print0 option to
find and the -0 option to xargs.

But there's no need to use find/xargs.

To magically look after the directory bits, you 
use the chmod big X option rather than the small x.
Big X sets x if any other x is set.  This
will do the right thing in the sense that the result
would be the same if you set the desired umask
before creating the files:

$ umask
0007
$ touch crap1
$ mkdir crapdir
$ ls -l
total 4
-rw-rw1 mlh  mlh 0 Aug 12 20:54 crap1
drwxrwx---2 mlh  mlh  4096 Aug 12 20:54 crapdir
$ chmod -R o+rX .
$ ls -l
total 4
-rw-rw-r--1 mlh  mlh 0 Aug 12 20:54 crap1
drwxrwxr-x2 mlh  mlh  4096 Aug 12 20:54 crapdir


Matt
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] recursively change file permissions not directories

2003-08-14 Thread Christopher Vance
On Tue, Aug 12, 2003 at 11:32:06AM +1000, Ram Smith wrote:
: I have a shared directory structure where alot of the files in each
: directory have permisions of 644 I wanting to change it so that the
: files are chmod 664 letting all users in the group read and write to the
: data. without nuking the permissions on the directories along with the
: files.
: 
: chmod -R won't work. There doesn't appear to be an option to
: exclude dirs with chmod.
: 
: how would you go about doing this.

find wherever -type f | xargs chmod g+w

or maybe change g+w to 664 if you know nothing there needs to be executable

-- 
Christopher Vance
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


RE: [SLUG] recursively change file permissions not directories

2003-08-14 Thread Andrew McNaughton

yes, find ... -exec is a good deal safer.  It used to be that it was based
on (properly escaped) file names, and there was a lot of discussion over
the implications of this for cleaning out the temp directory.  If it uses
file names then there's a potential race condition which can be used to
substitute a symlink for a deeply nested directory tree so that the actual
exec points to some arbitrary file.

Andrew





On Tue, 12 Aug 2003, Rowling, Jill wrote:

 Date: Tue, 12 Aug 2003 17:27:12 +1000
 From: Rowling, Jill [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: RE: [SLUG] recursively change file permissions not directories

 The sequence find . -exec seems safe enough though.
 I suspect it just uses the inode numbers rather than the file name or
 something (but beware this is on Solaris ;)
 bash-2.05$ find thingy -type f -exec file {} \;
 thingy/one/this:empty file
 thingy/two/; file thingy:   empty file
 thingy/three/that:  empty file
 bash-2.05$ ls -lR thingy
 thingy:
 total 6
 drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 one
 drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 three
 drwxrwxr-x   2 rowling  staff512 Aug 12 17:22 two

 thingy/one:
 total 0
 -rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 this

 thingy/three:
 total 0
 -rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 that

 thingy/two:
 total 0
 -rw-rw-r--   1 rowling  staff  0 Aug 12 17:22 ; file thingy
 bash-2.05$

 - Jill


--

No added Sugar.  Not tested on animals.  May contain traces of Nuts.  If
irritation occurs, discontinue use.

---
Andrew McNaughton   In Sydney
Working on a Product Recommender System
[EMAIL PROTECTED]
Mobile: +61 422 753 792 http://staff.scoop.co.nz/andrew/cv.doc



-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug