1. Find is a very effective tool. It can traverse the current directory or even the entire file system to find some files or directories.
Main options:
-Name: searches for files by file name
-Perm searches for Objects Based on file permissions.
-Prune is not found in the specified directory.
-The user searches for files based on the file owner.
-Group: searches for files based on the group to which the files belong.
-Mtime-N + N: Find the file based on the file change time.-N indicates that the file change time is earlier than N days, and + N indicates that the file change time is earlier than N days.
-Nogroup: Find the file with no valid group, that is, the group to which the file belongs does not exist.
-Nouser: Search for files without a valid owner
-Newer file1! File2 searches for files whose change time is newer than file1 but older than file2.
-Type: search for a certain type of file
[File type:
Block B Device Files
D directory
C character Device File
PS channel File
L symbolic link file
F Common File
]
-Size N [c]: searches for files with a file length of N blocks. If the file contains C, the file length is measured in bytes.
-When searching for files, depth first searches for files in the current directory, and then searches for files in its subdirectories.
-Mount does not span the mount point of the file system when searching for files.
-Follow: If the find command encounters a symbolic link file, it will trace the file pointed to by the link.
-Cpio: Use the cpio command to back up the files to the disk device.
(For other options, see man find)
Examples of the find Command Options:
$ Find/etc-type D # search all directories under the/e t c directory
$ Find/etc-user yaoyuan # Find the file whose owner is yaoyuan in the/etc directory
$ Find.-size + 000000c # search for files with a length greater than 1 MB in the current directory
2. The whereis command searches for qualified files in the specified directory. The attributes of the files should belong to the original code, binary files, or help files.
Option:
-B: Only query binary files.
-B only searches for binary files in the Set Directory
-F does not display the path name before the file name
-M: only find the instruction file.
-M: only find the instruction file in the specified directory.
-S: Only search for original code files
-S: Only search for the original code file in the Set Directory
-U: Find Files that do not contain the specified type
Whereis example
$ Whereis MySQL
MySQL:/usr/bin/MySQL/etc/MySQL/usr/share/man/Man1/mysql.1.gz
3. The locate command is used to find the files that meet the conditions. It stores the files and directories in the database with the directory names and finds the files or directories that meet the conditions.
Option:
-U: Create a database starting from the root directory.
-U: You can specify the start location to create a database.
-E will be excluded from the search range
-F exclude a specific File System
-Q quiet mode, no error message is displayed
-N: display up to N outputs
-R: Conditions for searching using regular expressions
-O: Specifies the data inventory name.
-D specifies the database path
-H: displays the secondary message
-V: show more messages
-V: displays the version information of the program.
(The locate command can be used to quickly find files when searching for a database. The database is updated by the updatedb program, and the updatedb is periodically created by the cron daemon, the locate command is faster than searching for data from the entire hard disk, but worse is that the files found by the locate are created recently or renamed, it may not be found. In the specified value, updatedb runs once a day. You can modify crontab to update the set value. (Etc/crontab)
Locate is used to search for qualified files. It stores the files and directories in the database to find files or directories that meet the template style conditions, special characters (such as "*" or "? ", Etc.) to specify the template style. For example, if the template is named kcpa * NER, locate will find all the files or directories whose start string is kcpa and end with ner, for example, if the directory name is kcpartner and the directory name is kcpa_ner, all files including subdirectories in the directory are listed. )
Example of locate:
$ Locate inittab
/Usr/lib/upstart/migrate-inittab.pl
/Usr/share/terminfo/A/ANSI + inittabs
Link: http://www.iteye.com/topic/406709