[ILUG] CHMOD

Brian Foster blf at utvinternet.ie
Sun Jan 11 12:27:03 GMT 2009


  | Date: Fri, 9 Jan 2009 23:45:28 +0000
  | From: "Alan Ryan" <alan at codecrunchers.ie>
  |[ ... ]
  | You can use the find command to exercise some control over what gets
  | modified  [ spurious `*'s deleted -blf]
  | 
  |  find . ! -type f -exec chmod a+w {} \;
  | 
  | find everything that is not a file and make it writeable.... i.e make
  | all dirs writeable ...

 also named pipes, special files, sockets, and anything
 else which is not a plain file.  and using -exec is daft.

 whenever I unpack a tarball (or similar), about the fist
 thing I then do is (`.' is the root of the unpacked tarball):

    find . -type d -print0  |  xargs -0 chmod a+rx,go-w
    find . -type f -print0  |  xargs -0 chmod a+r,a-w

 the first ensures everyone has access to all the directories,
 but that, at the most, the only user who can write to any of
 the directories is the owner (me).  the second ensures all
 the files are readable by everyone and not writable by anyone
 (including me).  whilst the above doesn't prevent accidental
 deletions/renames, it does discourage other accidents.
 (it can also sometimes break builds, usually do to a poor
 assumption in the Makefile that it can always overwrite a
 generated file when generating a new version.)

 I also use numeric chmod permissions (e.g., 777); for me,
 the key difference in the two notations is the symbolic
 notation _allows_ specifying changes _relative_ to the
 existing permissions whilst the numeric does not allow
 doing that.  I find it easier to determine and type
 the number if I just want to set the permission (which
 is, perhaps, the usual case?), so I do tend to use the
 numeric notation much more than the symbolic.

cheers!
	-blf-
-- 
“How many surrealists does it take to    |  Brian Foster
 change a lightbulb?  Three.  One calms  |  somewhere in south of France
 the warthog, and two fill the bathtub   |     Stop E$$o (ExxonMobil)!
 with brightly-coloured machine tools.”  |       http://www.stopesso.com



More information about the ILUG mailing list