chmod equivalent to find commands

Loren M. Lang lorenl at alzatex.com
Sun Mar 13 02:09:14 PST 2005


On Sat, Mar 12, 2005 at 06:53:59AM -0500, Fafa Diliha Romanova wrote:
> hello.
> 
> i know there's an equivalent to these two find commands that
> can be summed up in one chmod command:
> 
> find . -type d -exec chmod 755 {} \;
> find . -type f -exec chmod 644 {} \;

The EXACT equivalent would be:

find . -type d -exec chmod u=rwx,go=rx {} \;
find . -type f -exec chmod u=rw,go=r {} \;

But I take it that that isn't exactly what your looking for.  Your
probably looking for something like "chmod -R u=rwX,go=rX ."

> 
> it fixes my permissions ...
> i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX

This may work it depends on exactly what you need to do and how bad your
permissions are messed up.  Instead of a+rX, it might be better to do
go+rX since you already have u covered, but I don't think it will make a
big difference.  Also, this adds to the existing permissions, it won't
take away any permissions like my example earlier does.  Lastly, the big
difference between this and the find version is that the find version,
both mine and yours, will set the execute bit on all directories and not
on any normal files where the recursive chmod with the X permission with
set the x permission on any file/directory that already has at least one
type of execute permission already set and not on any other files or
directories.  So if your permissions are messed so badly that you have
directories without any execute permission, this won't fix that.  The
find version on the other hand will ignore everything that is not a
normal file or directory (i.e. fifos, sockets, device files), but this
probably won't be a big deal either.  The single recursive chmod I gave
you will most likely be what you need.

> 
> what would be the best solution here?
> 
> thanks,
> -- fafa
> 
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

-- 
I sense much NT in you.
NT leads to Bluescreen.
Bluescreen leads to downtime.
Downtime leads to suffering.
NT is the path to the darkside.
Powerful Unix is.

Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc
Fingerprint: CEE1 AAE2 F66C 59B5 34CA  C415 6D35 E847 0118 A3D2
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050313/cb217856/attachment.bin


More information about the freebsd-questions mailing list