Follow the file permission mode with the-perm option to find files by file permission mode. It is best to use the octal permission notation.
For example, in the current directory to find file permission bit 755 file, that is, the file owner can read, write, execute, other users can read, execute files, can be used:
de>$ find. -perm 755-printde> There is also a way of expression: in front of the octal number to add a bar-, the expression is matched, such as 007 is equivalent to 777,-006 equivalent to 666
de># ls-l -rwxrwxr-x 2 Sam Adm 0 October 01:01 http3.conf -rw-rw-rw-1 Sam Adm 34890 October 00:57 httpd1.conf -rwxrwxr-x 2 Sam Adm 0 October 01:01 httpd.conf Drw-rw-rw-2 Gem Group 4096 October 19:48 Sam -rw-rw-rw-1 root root 2792 October 20:19 Temp
# Find. -perm 006 # Find. -perm-006 ./sam ./httpd1.conf ./tempde> -perm mode: File license exactly matches mode
-perm +mode: File License section complies with mode
-perm-mode: File license fully complies with mode
Let's start by creating one of the following examples
#ls-L/testdir --s-1 root root 0 2008-05-06 10:39 2000 -s--1 root root 0 2008-05-06 10:39 4000 -s–s-1 root root 0 2008-05-06 10:39 6000 -rws–s-1 root root 0 2008-05-06 10:39 6600
I created 4 files, all with suid/sgid bits. Suppose I do Find. -type F-perm 6000 Then obviously we can get the following results. ./60000 This is an exact match.
If you execute find. -type f-perm-6000, the result is:
./6000 ./6600
Here the-number indicates that 1 of the position must be correctly matched, the other does not matter. To turn this into binary, the first 6000 turns into a three-bit binary is like this 110 000 000 000 This means that the front two 1 must match, the other does not matter. that matches the 6000,6600. Two files, whose permissions are converted to binary.
110 000 000 000 110 110 000 000
And if you are executing find. -type F-perm +6000, what will the result be?
Let's see the results.
./6000 ./2000 ./4000 ./6600
The + number means that as long as there is a 1 match on the line, that is, the first 2 bits, as long as there is a 1 on the line, so the above all meet the requirements, because the translation into binary into
110 000 000 000 010 000 000 000 100 000 000 000 110 110 000 000
So, from the above results can be seen, command find. -type f-perm +6000 is all programs with Suid/sgid in the specified directory.
This is an instruction that should be used frequently when doing safety maintenance. Let's start by creating one of the following examples
#ls-L/testdir --s-1 root root 0 2008-05-06 10:39 2000 -s--1 root root 0 2008-05-06 10:39 4000 -s–s-1 root root 0 2008-05-06 10:39 6000 -rws–s-1 root root 0 2008-05-06 10:39 6600
I created 4 files, all with suid/sgid bits. Suppose I do Find. -type F-perm 6000 Then obviously we can get the following results. ./60000 This is an exact match.
If you execute find. -type f-perm-6000, the result is:
./6000 ./6600
Here the-number indicates that 1 of the position must be correctly matched, the other does not matter. To turn this into binary, the first 6000 turns into a three-bit binary is like this 110 000 000 000 This means that the front two 1 must match, the other does not matter. that matches the 6000,6600. Two files, whose permissions are converted to binary.
110 000 000 000 110 110 000 000 And if you are executing find. -type F-perm +6000, what will the result be? Let's see the results.
./6000 ./2000 ./4000 ./6600
The + number means that as long as there is a 1 match on the line, that is, the first 2 bits, as long as there is a 1 on the line, so the above all meet the requirements, because the translation into binary into
110 000 000 000 010 000 000 000 100 000 000 000 110 110 000 000
So, from the above results can be seen, command find. -type f-perm +6000 is all programs with Suid/sgid in the specified directory.
This is an instruction that should be used frequently when doing safety maintenance. |