Howard,

Alternatively, if you have a directory tree in which you know
the permissions you'd like to have for files and directories,
you can set them all en masse.  This probably runs fast enough
to suit you and avoids doing a bunch of manual work in the event
that there are lots of files with incorrect permissions.

To change directories::

  find -type d -exec chmod 770 {} +

To change files::

  find -type f -exec chmod 660 {} +

There are fancier options to ``chmod`` to adjust some permission
bits without changing others, but the above is pretty simple
when you know what you want for the entire set of permission
bits.

Michael Henry

On 05/23/2017 12:20 AM, Ben Stern wrote:
> find . -perm 0444 -print -o -perm 0440 -print -o -perm 0400 -print
>
> Assuming they're not mode 0000 or 0040 or something goofy.
>
> man find and look at the examples of -perm -mode , -perm /mode
> , and the examples.
>
> Ben
>
> On Mon, May 22, 2017 at 08:57:12PM -0700, Howard Sanner wrote:
>> Is there any easy way (easy = I don't have to write a program
>> in C) to search for files in a directory tree with certain
>> permissions? I looked at the man page for ls and didn't see
>> anything obvious.
>>
>> Here's what's going on. At some point some of my WAV files
>> got their permissions set to read only. I don't know whether
>> that's because I got the not-so-bright idea that that way
>> they couldn't be deleted, or if I used chmod recursively
>> without thinking through the ramifications. Either way, now,
>> when I try to back them up to a USB HD, I get lots of
>> permission denied error messages when trying to copy those
>> files.
>>
>> I've fixed a lot of them by hand, but there are still some
>> "problem children" out there. So if I could find all the
>> files for which the owner has only read permission and
>> directories for which the owner has other than rwx
>> permission, that would be A Good Thing. Since there are
>> hundreds of GB of these files, running cp -a -r until it
>> reports an error is very time consuming.
>>
>> Thanks for your advice.
>>
>> Howard Sanner linux-au...@terrier.ampexguy.com a Terp of 1975
>> vintage

Reply via email to