Explaining Find Command's "-perm mode", "-perm -mode" & "-perm /mode" in Linux

  • Thread starter shivajikobardan
  • Start date
  • Tags
    Linux
In summary, the conversation discusses the use of the "find" command and its different options for finding files based on permissions. The commands "-perm 644", "-perm -600", and "-perm /700" are explained and their potential use cases are mentioned, such as checking for vulnerable files or monitoring for unauthorized changes.
  • #1
shivajikobardan
674
54
TL;DR Summary
When to use "-perm mode", "-perm -mode" and "-perm /mode" in find command Linux?
I am reading the find documentation and find this pretty confusing.

I'll try to explain what I've understood. You can add your explanation to this.


Code:
 .
    ├── file1.txt (Permission: 644)
    ├── file2.txt (Permission: 600)
    └── subdir
        ├── file3.txt (Permission: 755)
        └── file4.txt (Permission: 700)

Say we have a scenario like this.
Code:
    $ find . -perm 644
    ./file1.txt

Here the -perm 644 will exactly match for files that have permission 644.

Code:
    $ find . -perm -600
    ./file1.txt
    ./file2.txt

Here the -perm -600 will find any find that have at least 600 as permission.

Code:
    $ find . -perm /700
    ./file2.txt
    ./subdir/file3.txt
    ./subdir/file4.txt

Here -perm /700 finds files that have any of 7,0,0 as their permission bit set.

Is my understanding correct and what are the potential use cases of these respective commands?
 
Technology news on Phys.org
  • #2
You could be looking for supposedly private files that are publicly readable or executable.

One use case might be others are doing maintenance on your machines and you want scripts that can check for vulnerabilities such as allowing some file to be executed or changed that shouldn't be.
 

Similar threads

Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
  • Computing and Technology
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Special and General Relativity
Replies
13
Views
2K
  • Special and General Relativity
Replies
1
Views
2K
Back
Top