bash:find:find_files_based_on_their_permissions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bash:find:find_files_based_on_their_permissions [2022/06/13 08:39] – peter | bash:find:find_files_based_on_their_permissions [2022/06/13 08:59] (current) – peter | ||
---|---|---|---|
Line 7: | Line 7: | ||
</ | </ | ||
+ | <WRAP info> | ||
**NOTE: | **NOTE: | ||
Line 12: | Line 13: | ||
* 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. |
+ | |||
+ | </ | ||
---- | ---- | ||
Line 33: | Line 36: | ||
---- | ---- | ||
- | Now, let us use “-” prefix | + | ===== Using "-" |
<code bash> | <code bash> | ||
Line 39: | Line 42: | ||
</ | </ | ||
- | The above command displays two files. | + | <WRAP info> |
+ | **NOTE: | ||
- | 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”. | + | * 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. | + | </ |
---- | ---- | ||
- | Next, we will use “/” prefix | + | ===== Using "/" |
<code bash> | <code bash> | ||
Line 55: | Line 60: | ||
</ | </ | ||
- | The above command | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
<code bash> | <code bash> | ||
Line 61: | Line 69: | ||
</ | </ | ||
- | This command | + | <WRAP info> |
+ | **NOTE: | ||
+ | |||
+ | * That means the files do not have to be writable by both the owner and group to be matched; either will do. | ||
+ | |||
+ | </ | ||
- | But if you run the same command with “-” prefix, you will only see the files only which are writable by both owner and 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. |
<code bash> | <code bash> | ||
find -perm -220 | find -perm -220 | ||
</ | </ | ||
- | |||
- | The following screenshot will show you the difference between these two prefixes. | ||
---- | ---- | ||
Line 75: | 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 | + | Symbolic |
- | For instance, | + | <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). | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== To find any file with group write permissions ==== | ||
<code bash> | <code bash> | ||
Line 83: | Line 104: | ||
</ | </ | ||
- | 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 | + | <WRAP info> |
+ | **NOTE: | ||
+ | |||
+ | * It does not matter. | ||
+ | |||
+ | </ | ||
+ | |||
+ | For example, the following two commands will do the same thing. | ||
<code bash> | <code bash> | ||
Line 90: | Line 118: | ||
</ | </ | ||
- | 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 96: | Line 126: | ||
</ | </ | ||
- | 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 102: | Line 134: | ||
</ | </ | ||
- | 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 108: | Line 142: | ||
</ | </ | ||
- | The above command is equivalent of “find -perm -220” command. | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
- | 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 122: | Line 161: | ||
</ | </ | ||
- | These two commands | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Help ===== | ||
For more details, refer the man pages. | For more details, refer the man pages. | ||
Line 130: | Line 175: | ||
</ | </ | ||
- | Also, check the man pages alternatives to learn more simplified examples of any Linux command. | + | |
bash/find/find_files_based_on_their_permissions.1655109549.txt.gz · Last modified: 2022/06/13 08:39 by peter