I had a strange situation where I've found a number of files and folders that had 000 permissions set. This was easily repairable via:

sudo find . -perm 000 -type f -exec chmod 664 {} \; 
sudo find . -perm 000 -type d -exec chmod 775 {} \;

Unfortunately I suddenly realized the problem was a bit more complicated with some odd permissions such as 044 and some other strange settings. It turns out that these are strewn about and unpredictable.

Is there a way to search for permissions such as 0** or other such very limiting permission configurations?


I'd use something like this:

find . ! -perm -u=r ! -perm -u=w ! -perm -u=x -ls

Or if you prefer the octal notation:

find . ! -perm -400 ! -perm -200 ! -perm -100 -ls

Unfortunately, no idea, how to take it as one -perm option.

That syntax above is standard except for the -ls part (common but not POSIX) which you can replace with -exec ls -disl {} + on systems where find doesn't support -ls to get a similar output.

  • @Stéphane Chazelas any arguments for use ! instead of -not ? IMHO it generates only problems in scripts, breaking pipes, needs to escape e.t.c. – Alexander Aug 27 '18 at 14:00
  • 2
    -not is not standard, ! alone is never a problem, it's even the name of a POSIX shell keyword (!) and it's commonly used as argument to the [ / test command in addition to find. – Stéphane Chazelas Aug 27 '18 at 14:01

With GNU find, you can do this by looking for files which don’t match “any bit set for the owner”:

find . ! -perm /700

The same in e.g. FreeBSD find is

find . ! -perm +700

Both of these work in the same way. -perm /700 or -perm +700 match if any of the owner permission bits are set; ! negates that, so ! -perm /700 or ! -perm +700 match if none of the owner permission bits are set. The other bits are ignored.

  • Oh so the / operator inverts the bit of the first one? Ie, if I were looking for group instead would this be applied to the 2nd bit? Just curious now at this point to understand the permission functionality better. Also, just tried on macOS and got the following error when run interactively: find: -perm: /700: illegal mode string – ylluminate Aug 27 '18 at 13:34
  • 1
    Ah, sorry, -perm / is a GNU extension which matches any of the given permission bits. – Stephen Kitt Aug 27 '18 at 13:41
  • Thanks for clarifying, that would have been great and the answer had it worked for macOS' find. – ylluminate Aug 27 '18 at 19:10
  • @ylluminate: To directly and more clearly answer your follow-up question (in the comment above): No, / doesn’t “invert” anything.  ! is the “NOT” operator, inverting the following test.   / is effectively an “OR” operator; find . ! -perm /700 is equivalent to find . ! "(" -perm -400 -o -perm -200 -o -perm -100 ")" — which is equivalent to find . ! -perm -400 ! -perm -200 ! -perm -100, which is directly equivalent to Alexander’s answer.  As Stephen said, / means “any of these bits”. – Scott Aug 27 '18 at 21:35
  • 1
    @ylluminate, find . ! -perm +700 works with the find on Mac. – ilkkachu Aug 27 '18 at 21:38

If you use sfind or any program using libfind or if you use BSD find, you may use:

find path -perm +0xxx

to find files where any of the bits mentioned in the pattern are set, so

find . ! -perm +0700

should work in your case. BTW: this is also supported by GNU find.

Note that this is an extension that is neither mentioned in POSIX nor implemented in a SVr4 based find.

  • Note that it was how GNU find (from 1991 to 2013, deprecated after 2005) used to do it as well, but they replaced it with -perm /0700 for POSIX compliance. – Stéphane Chazelas Aug 27 '18 at 15:12
  • Since smake supports this feature using + and since I am very sure that smake is POSIX compliant, as it permits this special enhancement only in case that the + is followed by 0, u, g, o or a, I see no reason for this change. – schily Aug 27 '18 at 15:20
  • find -perm +u is specified by POSIX (as being the same as -perm 0). It's not clear for -perm +0777, where +0777 could be considered as a non-negative octal number – Stéphane Chazelas Aug 27 '18 at 15:45
  • Sorry, this is not in the POSIX standard. The plus sign is only specified after ugoa or before rwx and similar chars. – schily Aug 27 '18 at 16:12
  • chmod +u is specified (gives all the same permission as the user, filtered by umask), so find -perm +u is as well. Also note how the find -perm spec makes it explicit that one can't use a perm that starts with - as it would conflict with -perm -mode, but there's no such thing for +. – Stéphane Chazelas Aug 27 '18 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.