LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2012, 01:52 PM   #1
diamond_D
Member
 
Registered: Jul 2005
Posts: 51

Rep: Reputation: 0
Linux find command -perm mode confusion


I'm having some difficulty trying to figure out the difference when using the 'find -perm' command modes.

-perm permissions - Find files with exact permissions. (I get this one)

-perm -permissions - Find files with all the specified permissions.

-perm /permissions - Find files with any of the specified permissions.

I guess my difficultly is distinguishing when to use the '-perm -mode' and 'perm /or+ mode'.

I'm doing some practice questions and got tripped up on the following:

Which command can be executed to find all the files in the current directory for which the file owners have read and write permissions?

My answer: find -perm +0600
Correct answer: find -perm -0600

I then see a bunch of examples on the net where people commonly use -perm to find the SGID/SUID files on the system.
find / -type f -perm +6000 -ls

Why is +6000 used as opposed to -6000?

If somebody could please help me understand this, it would be greatly appreciated.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-05-2012, 02:18 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
The difference between the "-mode" and the "/mode" is similar to logical AND and logical OR.

But first, in either case, the 0's are "don't cares" -- meaning that the corresponding permissions for the examined file can be either allowed/denied and they will make no difference regarding how the test will evaluate.

But keep in mind that the 0's do matter in the first case--where you specify exact permissions to find.

Back to the logical AND and logical OR.

When using "-mode" you are using logical AND. You would read the option "-perm -0600" as:
permission 0400 allowed (owner: read) AND permission 0200 allowed (owner: write) while the rest can be any combination of allowed/denied.

When using "/mode" you are using logical OR. You would read the option "-perm /0600" as:
permission 0400 allowed (owner: read) OR permission 0200 allowed (owner: write) while the rest can be any combination of allowed/denied.

Does that help, or are you looking for practical examples?
 
2 members found this post helpful.
Old 03-05-2012, 08:59 PM   #3
diamond_D
Member
 
Registered: Jul 2005
Posts: 51

Original Poster
Rep: Reputation: 0
Now I have an understanding.

Much thanks to Dark_Helmet!!

Last edited by diamond_D; 03-05-2012 at 09:02 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
find / -type f -perm +6000 - 32 lines of output, should it be less ? crispyleif Linux - Security 1 06-20-2009 03:40 AM
find / -perm +020????? pepe0121 Linux - Newbie 1 01-04-2008 08:42 AM
find -perm the_imax Linux - General 2 12-05-2007 03:57 PM
Remove symbolic links from output of find . -perm helptonewbie Linux - Newbie 2 10-31-2007 11:03 AM
find / \( -perm -0200 -o -perm -04000 \) -ls. How to remove the bit ForumKid Linux - Security 3 01-16-2002 12:36 PM


All times are GMT -5. The time now is 01:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration