Unix/Linux Go Back    

UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

find -perm query

UNIX for Dummies Questions & Answers

Thread Tools Search this Thread Display Modes
Old Unix and Linux 11-28-2006
napolayan napolayan is offline
Registered User
Join Date: Oct 2006
Last Activity: 8 April 2009, 2:10 PM EDT
Location: Bangalore, India
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
find -perm query

I was going through a find tutorial and just couldn't get it...can someone explain it like he/she would explain a brain damaged dodo?

"find allows you to specify a pattern that can be bit-wise ANDed with the permissions of the file. Simply put a minus sign before the octal value. The group write permission bit is octal 20, so the following negative value:

find . -perm -20 -print

will match the following common permissions:

|Permission Octal value |
|rwxrwxrwx 777 |
|rwxrwxr-x 775 |
|rw-rw-rw- 666 |
|rw-rw-r-- 664 |
|rw-rw---- 660 |
If you wanted to look for files that you can execute, (i.e. shell scripts or programs), you want to match the pattern "--x------," by typing:

find . -perm -100 -print

When the -perm argument has a minus sign, all of the permission bits are examined, including the set user ID bits. "

so the question is: what is the calculation behind the 20 in '-perm -20' and the 100 in '-perm -100'?


Brain Damaged Dodo
Sponsored Links
Old Unix and Linux 11-28-2006
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Advisor  
Unix Daemon (Administrator Emeritus)
Join Date: Aug 2001
Last Activity: 26 February 2016, 12:31 PM EST
Location: Ashburn, Virginia
Posts: 9,930
Thanks: 64
Thanked 471 Times in 271 Posts
You have to know octal - binary conversion. 020 in octal is 000010000 in binary. And looking at the permission bits:
rwx rwx rwx
000 010 000

So we start with all zeros and replace the zero with a one if we are interested in that bit. Then we convert to octal. See my article on file permissions in our tips and tutorials section for more info.
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find query duckeggs01 Shell Programming and Scripting 2 12-22-2011 06:34 AM
Help with find -perm option stevensw Shell Programming and Scripting 7 04-16-2011 01:01 PM
find and replace query lightdensity Shell Programming and Scripting 11 05-27-2009 07:15 AM
Wild card in find perm braindrain Shell Programming and Scripting 1 04-12-2007 06:24 PM
query about find and -exec shriashishpatil UNIX for Advanced & Expert Users 2 04-12-2007 01:16 AM

All times are GMT -4. The time now is 08:08 AM.