[Gllug] How to chmod selectively without writing a script
Matthew Kirkwood
matthew at hairy.beasts.org
Tue Oct 1 14:41:00 UTC 2002
On Tue, 1 Oct 2002, Liad Bokovsky wrote:
> >find . -type d -exec chmod 755 {} \; # finds directories and applies chmod
> >find . -type f -exec chmod 644 {} \; # finds regular files and applies chmod
>
> as an old dog, I'm still using one of the old tricks I've learnt.
>
> find . -type d |xargs chmod 755 - for directories and sub-dirs'
> find . -type f |xargs chmod 644 - for files
You'll regret that if any of your filenames have
newlines in them. Try:
find . -type d -print0 | xargs -0 chmod 755
find . -type f -print0 | xargs -0 chmod 644
However, here a new trick that even old dogs may
not have seen:
chmod -R u+w,og-w,a+rX .
It's not directly equivalent, but may actually
be a better fit. "+X" does "set the x bit if
it's already set for anybody". Unless your
permissions are badly busted, your directories
will probably have the x bit set for the owner
or group. The above will also open up perms
on executables, which is useful if it's a build
tree or similar.
Matthew.
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list