On Tue, 23 May 2017, 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.
The -perm -mode and -perm /mode are usually more useful than -perm mode.
The former checks if the ALL permission bits given are set, the latter
if ANY are set.
So to find all files under rootdir for which owner does not have rwx perms,
something like
find rootdir ! -perm -u=rwx
where the ! is logically negating the test (file owner has all of rwx set),
and taking advantage of fact that most/all linuxes should support symbolic
permissions in find command.
Indeed,
find rootdir ! -perm -u=rwx -exec chmod u+rwx {} \;
will find all such files and then set rwx for file owner.
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
--
Ben Stern
This space intentionally left blank.
Tom Payerle
DIT-ATI-Research Computing paye...@umd.edu
4254 Stadium Dr (301) 405-6135
University of Maryland
College Park, MD 20742-4111