Next: , Previous: Owner, Up: Finding Files



2.7 Permissions

See File Permissions, for information on how file permissions are structured and how to specify them.

— Test: -perm mode

True if the file's permissions are exactly mode (which can be numeric or symbolic).

If mode starts with -, true if all of the permissions set in mode are set for the file; permissions not set in mode are ignored. If mode starts with +, true if any of the permissions set in mode are set for the file; permissions not set in mode are ignored.

If you don't use the + or - form with a symbolic mode string, you may have to specify a rather complex mode string. For example -perm g=w will only match files which have mode 0020 (that is, ones for which group write permission is the only permission set). It is more likely that you will want to use the + or - forms, for example -perm -g=w, which matches any file with group write permission.

-perm 664
Match files which have read and write permission for their owner, and group, but which the rest of the world can read but not write to. Files which meet these criteria but have other permissions bits set (for example if someone can execute the file) will not be matched.
-perm -664
Match files which have read and write permission for their owner, and group, but which the rest of the world can read but not write to, without regard to the presence of any extra permission bits (for example the executable bit). This will match a file which has mode 0777, for example.
-perm +222
Match files which are writeable by somebody (their owner, or their group, or anybody else).
-perm +022
Match files which are writeable by either their owner or their group. The files don't have to be writeable by both the owner and group to be matched; either will do.
-perm +g+w,o+w
As above.
-perm +g=w,o=w
As above
-perm -022
Search for files which are writeable by both their owner and their group.
-perm -g+w,o+w
As above.