How do I find files with no group permissions?
You can use:
find . \! -perm /070
Or:
find . \! -perm /g+rwx
This works because:
-
When the operand of the
-perm
test starts with/
, it causes-perm
to test if any of the specified permissions are present.(If you used
-
in place of/
, it would test if all were present. Without a prefix character, it would test for exactly the permission specified, i.e., all of them and no others present.) -
That's the opposite of what you're looking for -- none is the opposite of any -- and the not operator
\!
negates the result of the test that follows it.(The operator is really
!
, and you can probably write it that way, but it's commonly written as\!
to ensure that one's shell passes it on tofind
rather than treating it specially.)
As for the meaning of the specific strings after /
, see FilePermissions, this Wikipedia article, and/or man chmod
. In summary, as applied to the commands shown above:
-
070
is an octal permissions string, specifying permissions for user (i.e., owner), group, and other (i.e., everyone else), respectively. 7 is read (4), write (2), and execute (1) permissions (i.e.,111
has the1
bits in100
,010
, and001
). -
g+rwx
is a symbolic permissions string, specifying that the group (g
) has read (r
), write (w
), and execute (x
) permissions.
Whichever notation you use, remember that you're expressing the opposite of what you ultimately want, since the result of the test is negated by !
.
To find any file in the current directory or its subdirectories for which none group read, write or execute bits are set, run:
find . ! -perm /g+rwx