Summary of find, whereis, locate, and which file search commands in Linux

Source: Internet
Author: User
Http://hohoqi.blog.163.com/blog/static/10795561201091011199438/
FindFind is a very effective tool that can traverse the current directory or even the entire file system to find some files or directories. Main options:-name
Search for files by file name-Perm search for files by File Permission-prune not in the specified directory-user searches for files by file owner-group searches for files by file group- mtime-N + N searches for files based on the file change time, -N indicates that the file change time is less than N days ago, and + N indicates that the file change time is earlier than N days ago. -nogroup: searches for files with no valid owner group, that is, the group to which the file belongs does not exist.-nouser searches for files with no valid owner-newer file1! File2 searches for a file whose change time is newer than file1 but older than file2-type searches for a certain type of file [file type: b. device files D. directory c. Device Files P. Pipeline files L. Symbolic Link files F. Common files]-size N [C]. Find files with a file length of N, if the file contains C, the file length is measured in bytes.-when searching for a file, depth first looks for the file in the current directory, then, find in its subdirectory-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, you can use the cpio command to back up the files mapped to the file-cpio to the disk device. (for other options, see man find for further information) examples of the find Command Options:
$ Find/etc "hello" $ find/etc-type D # search all directories in the/etc directory $ find/etc-user yaoyuan # search for the file owner in the/etc directory $ find. -Size + 000000c # search for files with a length greater than 1 MB in the current directory WhereisThe 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 searches for binary files-B searches for binary files only in the Set directory-F does not display the path name before the file name-m only searches for description files-M is only in the Set Directory search description file-s only searches for the original code file in the Set directory-u searches for files that do not contain the specified type whereis example $ whereis MYSQL: /usr/bin/MySQL/etc/MySQL/usr/share/man/Man1/mysql.1.gz LocateThe locate command is used to find a qualified file. It stores the file and directory name in the database and finds the qualified file or directory. Option:-u to create a database, the database is created from the root directory-u. You can specify the starting location-E will be excluded from the search range-F will be excluded from the specific file system-Q quiet mode, no error message is displayed-n up to n outputs-r uses regular calculation to search for conditions-O specifies the name of the data inventory-D specifies the path of the database-H displays the auxiliary message -V: display more information-V: display the version information of the program (the locate command can quickly find the file when searching for the 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 the entire hard disk data to search for information in the database, however, if the files found by the locate are recently created or renamed, they may not be found. In the specified value, updatedb runs once a day and can modify cron. Tab to update the set value. (Etc/crontab) locate is used to search for qualified files. It stores the files and directory names 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. ) Locate example: $ locate inittab/usr/lib/upstart/migrate-inittab.pl/usr/share/terminfo/A/ANSI + inittabs WhichWhich is similar to where, but it is found in the set path of the environment variable. For example, [root @ localhost ~] # Which fdisk
/Sbin/fdisk Whereis
[Root @ localhost ~] # Whereis ls
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.