Linux is a "all-in-one" system, and the identity file in Linux does not pass the suffix, and the Find command searches for the entire system without specifying a lookup directory.
I. Command format
Find Pathname _options[-print-exec-ok ...]
pathname: The root directory that the Find command looks for. For example, use. To represent the current directory,/to represent the root directory.
Cases:
[Email protected]:~# find/root
/root
/root/file
/root/test2.txt
...
-print: The Find command outputs the matched file to standard output. (System default)
-exec commend {} \; : The Find command executes the shell command given by this parameter to the matching file
Example:[email protected]:~# find/root-type f-exec ls-l {} \;
-rw-r--r--1 root root 1490 may 05:08/root/file
-rw-r--r--1 root root 226 may 06:40/root/cmd
-rw-r--r--1 root root 0 may 18:57/root/test2.txt
-ok commend {} \;: Is the same as-exec, but prompts before executing each command, allowing the user to determine whether the execution, security
Two.-options: Find Rules
1.-name: Find files by file name//exact search
-iname: Find files by file name (case insensitive )
Example:[email protected]:~# find/root-name Test.txt
/root/test.txt
[Email protected]:~# find/root-iname test.txt
/root/test.txt
2.-perm follow file permissions to find files
Example:-rw-r--r--1 root root 0 may 18:57 Test2.txt
[Email protected]:~# find/root-perm 644
/root/test2.txt
-perm + permissions (a class of users can match write permissions)
-perm-Permissions (all category users satisfy Write permissions)
3.-user and-group: Find files by file owner and owning group
Example:[email protected]:~# find/root-user Root
/root
/root/file
/root/cmd
/root/test2.txt
...
4.-mtime-n +n: Depending on the file change time to find the file,-n means that the file change time to n days or less, +n indicates that the file changed time to now N days ago
Example:-rw-r--r--1 root root 1490 may 05:08 file
[Email protected]:~# find/root-mtime +2
/root/file
5.-nouser and-nogroup: The file belongs to the master that does not exist in/etc/passwd and the group to which the file belongs does not exist in/ect, groups
6.-type find some kind of file, for example:?
B-block device files.?
D-Directory.?
C-character device files.?
P-piping file.?
L-Symbolic link file.?
F-Normal file
Cases:
[Email protected]:~# find/root-type F
/root/file
/root/cmd
/root/test2.txt
...
7:-size n: [C] Find files with a file length of n block, with C indicating file length in bytes
-size +n or-size-n: Files greater than or less than n
Cases:
[Email protected]:~# find/root-size-226
/root
/root/file
/root/cmd
/root/test2.txt
...
8:-depth: When looking for a file, find the file in the current directory, and then look in its subdirectories
9:-fstype: Find files located in a file system of a certain type, these file system types can usually be found in the configuration file/etc/fstab, which contains information about the file system in this system.
10:-mount: The file system mount point is not spanned when locating files.
11:-follow: If the find command encounters a symbolic link file, it tracks to the file that the link points to.
12:-cpio: Use the cpio command for matching files to back up these files to the tape device.
The Find command in Linux