User Tools

Site Tools


bash:find:find_files_based_on_their_permissions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bash:find:find_files_based_on_their_permissions [2022/06/13 08:37] – created peterbash:find:find_files_based_on_their_permissions [2022/06/13 08:59] (current) peter
Line 7: Line 7:
 </code> </code>
  
-The MODE can be either with numeric or octal permission (like 777, 666.. etc) or symbolic permission (like u=x, a=r+x).+<WRAP info> 
 +**NOTE:**  The **MODE** can be either with numeric or octal permission (like 777, 666.. etc) or symbolic permission (like u=x, a=r+x).
  
-We can specify the MODE in three different ways as listed below.+The MODE can be specified in three different ways:
  
   * If we specify the mode without any prefixes, it will find files of exact permissions.   * If we specify the mode without any prefixes, it will find files of exact permissions.
-  * If we use “-“ prefix with mode, at least the files should have the given permission, not the exact permission. +  * If we use **“-“** prefix with mode, at least the files should have the given permission, not the exact permission. 
-  * If we use “/” prefix, either the owner, the group, or other should have permission to the file.+  * If we use **“/”** prefix, either the owner, the group, or other should have permission to the file.
  
-Allow me to explain with some examples, so you can understand better.+</WRAP>
  
 ---- ----
Line 29: Line 30:
 </code> </code>
  
-This command will find the files with permission of exactly 777 in the current directory.+<WRAP info> 
 +**NOTE:**  This command will find the files with permission of exactly 777 in the current directory. 
 +</WRAP>
  
-Now, let us use “-” prefix and see what happens.+---- 
 + 
 +===== Using "-" prefix =====
  
 <code bash> <code bash>
Line 37: Line 42:
 </code> </code>
  
-The above command displays two files.+<WRAP info> 
 +**NOTE:**  This will find all files where the file owner has read/write/execute permissions, file group members have read/write permissions and everything else has also read/write permission.
  
-We have set 766 permission to file2, but this command displays two files, why?+  * Yes, it will display files which do have 766 permissions.
  
-Because, here we have used “-” prefix”.  It means that this command will find all files where the file owner has read/write/execute permissions, file group members have read/write permissions and everything else has also read/write permission.+  * But this may also display some files which do not have exact 766 permissions
 +    * This could include files with tighter permissions too.
  
-In our case, file1 and file2 have met this criteria. In other words, the files need not to have exact 766 permission.  It will display any files that falls under this 766 permission.+</WRAP>
  
 ---- ----
  
-Next, we will use “/” prefix and see what happens.+===== Using "/prefix =====
  
 <code bash> <code bash>
Line 53: Line 60:
 </code> </code>
  
-The above command will find files which are writable by somebody (either their owner, or their group, or anybody else). Here is another example.+<WRAP info> 
 +**NOTE:**  This will find files which are writable by somebody (either their owner, or their group, or anybody else). 
 +</WRAP> 
  
 <code bash> <code bash>
Line 59: Line 69:
 </code> </code>
  
-This command will find files which are writable by either their owner or their group.  That means the files don’t have to be writable by both the owner and group to be matched; either will do.+<WRAP info> 
 +**NOTE:**  This will find files which are writable by either their owner or their group.
  
-But if you run the same command with “-” prefix, you will only see the files only which are writable by both owner and group.+  * That means the files do not have to be writable by both the owner and group to be matched; either will do. 
 + 
 +</WRAP> 
 + 
 +But if you run the same command with **“-”** prefix, you will only see the files only which are writable by both owner and group.
  
 <code bash> <code bash>
 find -perm -220 find -perm -220
 </code> </code>
- 
-The following screenshot will show you the difference between these two prefixes. 
  
 ---- ----
Line 73: Line 86:
 ===== Find Files Based On their Permissions using symbolic notation ===== ===== Find Files Based On their Permissions using symbolic notation =====
  
-In the following examples, we use symbolic notations such as u ( for user), g (group), o (others). We can also use the letter a to represent all three of these categories. The permissions can be specified using letters r (read), w (write), x (executable).+Symbolic notations is used such as u (for user), g (group), o (others).
  
-For instance, to find any file with group write permission, run:+<WRAP info> 
 +**NOTE:**  
 + 
 +  * The letter **a** can be used to represent all three of these categories. 
 +  * The permissions can be specified using letters r (read), w (write), x (executable). 
 + 
 +</WRAP> 
 + 
 +---- 
 + 
 +==== To find any file with group write permissions ====
  
 <code bash> <code bash>
Line 81: Line 104:
 </code> </code>
  
-As you see in the above example, file1 and file2 have group write permission. Please note that you can use either “=” or “+” for symbolic notation. It doesn’t matter. For example, the following two commands will do the same thing.+<WRAP info> 
 +**NOTE:**  You can use either **“=”** or **“+”** for symbolic notation. 
 + 
 +  * It does not matter. 
 + 
 +</WRAP> 
 + 
 +For example, the following two commands will do the same thing.
  
 <code bash> <code bash>
Line 88: Line 118:
 </code> </code>
  
-To find any file which are writable by the file owner, run:+---- 
 + 
 +==== Find any file which are writable by the file owner ====
  
 <code bash> <code bash>
Line 94: Line 126:
 </code> </code>
  
-To find any file which are writable by all (the file owner, group and everyone else), run:+---- 
 + 
 +==== Find any file which are writable by all (the file owner, group and everyone else) ====
  
 <code bash> <code bash>
Line 100: Line 134:
 </code> </code>
  
-To find files which are writable by both their owner and their group, use this command:+---- 
 + 
 +==== Find files which are writable by both their owner and their group ====
  
 <code bash> <code bash>
Line 106: Line 142:
 </code> </code>
  
-The above command is equivalent of find -perm -220” command.+<WRAP info> 
 +**NOTE:**  The above command is equivalent of **find -perm -220** command. 
 +</WRAP>
  
-To find files which are writable by either their owner or their group, run:+ 
 +---- 
 + 
 +==== Find files which are writable by either their owner or their group ====
  
 <code bash> <code bash>
Line 120: Line 161:
 </code> </code>
  
-These two commands does the same job as find -perm /220” command.+<WRAP info> 
 +**NOTE:**  These two commands do the same job as the **find -perm /220** command. 
 +</WRAP> 
 + 
 +---- 
 + 
 +===== Help =====
  
 For more details, refer the man pages. For more details, refer the man pages.
Line 128: Line 175:
 </code> </code>
  
-Also, check the man pages alternatives to learn more simplified examples of any Linux command.+
  
bash/find/find_files_based_on_their_permissions.1655109453.txt.gz · Last modified: 2022/06/13 08:37 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki