find-perm詳細

1806 ワード

-perm modeファイルの権限は、modeが-perm-modeファイルに一致する権限であり、modeが一致する(このファイルには追加の権限属性も持つことができる)-perm+modeファイルの権限部分がmodeを満たすと一致する(廃棄され、find新版で-perm/modeを使用)
例:4つのファイルを作成し、テストする
[root@localhost test]#touch {1..4}
[root@localhost test]#chmod 6000 1
[root@localhost test]#chmod 2000 2
[root@localhost test]#chmod 4000 3
[root@localhost test]#chmod 6600 4
[root@localhost test]# find . -perm 6000 -ls 
202028530    0 ---S--S---   1 root     root            0 Sep 22 17:31 ./1
[root@localhost test]# find . -perm -6000 -ls
202028530    0 ---S--S---   1 root     root            0 Sep 22 17:31 ./1
202028533    0 -rwS--S---   1 root     root            0 Sep 22 17:31 ./4
[root@localhost test]# find . -perm +6000 -ls 
find: warning: you are using `-perm +MODE'.  The interpretation of `-perm +omode' changed in findutils-4.5.11.  The syntax `-perm +omode' was removed in findutils-4.5.12, in favour of `-perm /omode'.
202028530    0 ---S--S---   1 root     root            0 Sep 22 17:31 ./1
[root@localhost test]# find . -perm /6000 -ls 
202028530    0 ---S--S---   1 root     root            0 Sep 22 17:31 ./1
202028531    0 ------S---   1 root     root            0 Sep 22 17:31 ./2
202028532    0 ---S------   1 root     root            0 Sep 22 17:31 ./3
202028533    0 -rwS--S---   1 root     root            0 Sep 22 17:31 ./4

ネット上で見た他の解釈は、見てみると、より明確に理解されます.
-perm mode:ファイル権限「ちょうど」modeのファイルを検索します.このmodeはchmodのような属性値です.例えば、-rwsr-xr-xの属性は4755です.-perm-mode:ファイル権限『modeの権限をすべて含まなければならない』のファイルを検索します.例えば、-rwxr--r--0744のファイルを検索します.-perm-0744を使用して、ファイルの権限が-rwsr-xr-x、つまり4755の場合もリストされます.-rwsr-xr-xの属性は-rwxr--r--の属性を含んでいるからです.-perm+mode:ファイル権限『いずれかのmodeを含む権限』のファイルを検索する.例えば、-rwxr-xr-x、すなわち-perm+755を検索すると、ファイル属性が-rw------であるため、-rwがある.の属性が存在します!