Reviewing permissions on dir/files recursively by exception

0

I need to view only the files in & below the directory I'm in that does not have the correct permissions: 700 or less for executable files AND 600 or less for non-executable files.

The directory I'm in and all those below it runs to 3,600 pages in a Word doc. Need to automate to a shell or command line (preferred) for a Solaris 10 server. thanks for any help.

JDW

Posted 2013-09-03T15:00:21.023

Reputation: 1

Answers

2

I suppose that you need to show the files that have at least the rw bit set for the user which is 600 as 600 should cover 700 rwx. Try

find . -perm -u=rw

if you want the opposite negate it, in the c-shell you will need to escape the negation or put a backslash before the !

find . \! -perm -u=rw

PaulB

Posted 2013-09-03T15:00:21.023

Reputation: 46

0

This is actually a fairly hard problem as stated.

By 'executable' you must mean something other than --x------- permissions -- the executable bit is set in the file mode. I think you mean: It is a compiled image or shell script or java byte code, etc.

To do that you have to use the file command, which interprets the "magic" at the start of a file: like #!/bin/bash at the very start of a shell script file. The good part of this is Solaris file gives wonderful answers - if you are a human. It provides LOTS of different answers.

If you are a program, good luck. A regular file that is "data" may say things like "ASCII text", "data file", and so on. IMO what you have to do is get a unique list of file "types" before you try to use find to differentiate what you want. You can make a list with find and awk.

cd /path/to/start/directory
find . -type f -exec /usr/bin/file {} \; | awk '!arr[$0]++' > /tmp/mylist

/tmp/mylist is a unique list of these "file types" Next step - a human will have to decide what entries in /tmp/my fit a definition of executable file and get or move the others to the "regular" pile. I've tried this in the past, so set aside some time to do it.

Update your post here with more information when you get it. Depending on what you get someone can show you what to do next.

jim mcnamara

Posted 2013-09-03T15:00:21.023

Reputation: 769