LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   file permissions find (https://www.linuxquestions.org/questions/programming-9/file-permissions-find-490417/)

ygloo 10-07-2006 03:46 PM

file permissions find
 
how to search for dirs/files which have
permissions greater than 755?

Savet 10-07-2006 11:52 PM

I'm sure someone will chime in with a more graceful option....

But the simplest way that comes to mind would be to search for files that don't have that set of permissions.

ls -lR /* |grep -v rwxr-xr-x |grep -v rwxr--r-- |etc...

Then you could direct it into a file and sift through it for what you're looking for.

HTH

ghostdog74 10-08-2006 12:36 AM

you can use find command too,
Code:

find /dir -type f -perm 777 -o -perm 776 -o -perm 766 ....
Not the most elegant though...

osor 10-08-2006 09:16 AM

I'm afraid that find doesn't filter based on whether a mode is greater than something. It goes by bits, so you can say ask it to match all files with at least the read, write, and executable bit set for the owner, and at least the read and executable bit set for the group and others. To do this, you want
Code:

find -perm -755
As you can see, the (very rarely occurring) modes 756, 765, and 766 are "greater than" 755, yet they will not be matched (because of their bitwise meanings). To get those as well, try
Code:

find -perm -755 -o -perm -766

soggycornflake 10-09-2006 01:25 PM

Your semantics are skewed. File permissions are bitfields, so one is not really "higher" than another. However, I assume you mean all files that are group/world writable and/or have suid/sgid/sticky bit set, in which case,

Code:

find / -perm +7022
should suffice.

find man page:

Quote:

-perm +mode
Any of the permission bits mode are set for the file.


All times are GMT -5. The time now is 10:44 PM.