Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I need to find all files with SUID recursively starting from root directory I can do it in two not so different ways:

find / -perm -4000

and the second one:

find / -perm +4000

Which variant is preferable and why?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Those are 2 different ways of searching. perm allows for 3 methods:

  1. -perm mode: permission bits set for the file are exactly that to match the search
  2. -perm -mode: all of the permission bits are set for the file to match the search
  3. -perm +mode: any of the permission bits are set for the file to match the search

So using - or + depends on what you want to find.

Examples:

find / -type f -perm 0777 will find all files set as rwxrwxrwx (owner, group AND other)

find / -type f +perm 0777 will find all files set as rwx for owner rwx for group OR rwx for other

Btw... it looks like the + is a the same as a '/`.

share|improve this answer
    
Can you explain 'any' case? –  om-nom-nom Jun 1 '11 at 11:24
    
I'll add in some examples. –  Rinzwind Jun 1 '11 at 11:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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