File Lookup command under Linux--find

Source: Internet
Author: User

(The document has three "time": http://zhweizhi.blog.51cto.com/10800691/1775447)


Overview


The Find command searches for a file of the specified name by traversing the hard disk, so its efficiency is much slower than the Whereis instructions.

The following describes the use of the Find command:



The command format is:

Find pathname [option] [action]


Pathname (PATH)

Where pathname is the path to find (. Indicates the current path,/represents the root path)

Such as

Find. -name test.c means looking for a file named TEST.c under the current path Find/-name test.c means looking for a file named TEST.c under the system root path


Option (parameter)

The following categories describe commonly used parameters:

-name: Find by file name

Such as:

Find. -name hello.c means looking for a file named hello.c under the current path


-perm: Search by file permissions

The root privilege here is 0.

Such as:

Find. -perm 755 chmod-r 777 means to find all files with permission 755 in the current directory and set to 777


-user according to the owner of the file to find


-group Search by the same group as the file


-nogroup finds a file that does not have a valid owning group, that is, the group to which the file belongs does not exist in/etc/groups.


-nouser finds a file without a valid owner, that is, the owner of the file does not exist in the/etc/passwd.


-newer file1! File2 find changes time than file File1 new, but file2 older files than files.


-type finding a file of a certain type

Such as:

B-block device files. D-Directory. C-character device file. P-Pipeline file. L-Symbolic link file. F-Normal file.


-size N:[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes.

For example:

Find/root-size-5557c-size +5555c-exec ls-ld {} \; A file that looks for a file length less than 5557 greater than 5555 (that is, a file of length 5556)




-depth: When looking for a file, first find the file in the current directory, and then look in its subdirectories.


-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.


-mount: Does not cross the file system mount point when locating files.


-follow: If the find command encounters a symbolic link file, it tracks to the file that the link points to.


-cpio: Use the cpio command for matching files to back up these files to the tape device.


-mtime-n +n (Mtime indicates the number of days, in addition to such as-mmin for minutes, the other two times the same)

-ctime-n +n

-atime-n +n

: Find files According to file change time (three kinds)

Such as:

Find/root-mmin 5 Find the directory accessed in the last 5 minutes of the system



Action (Action)


Once the lookup is complete, you can perform the specified action immediately, as follows:

Find. -size-11c-size +9c-delete Find files with file size of 10k and delete


File Lookup command under Linux--find

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.