Search for files in Linux Whereis, locate, find

Source: Internet
Author: User

Search for Linux files: Whereis, locate, find

Find lookup is relatively slow, because Whereis and locate use the database to find data, so it is relatively fast and does not actually query the hard disk, saving time.

    • Whereis (looking for a specific file) Whereis [-bmsu] file or directory name

-B: Find only files in binary format

-M: Only files found under the manual path of the description file

-S: Find source files only

-U: Find other special files that are not among the above three options

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/56/wKioL1c-bPTSkHBNAABqmOQvpX0539.png "title=" Image.png "alt=" Wkiol1c-bptskhbnaabqmoqvpx0539.png "/>

    • Locate locate [-ir] keyword

-I: Ignore case differences

-R: Can be followed by the display of regular expressions

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/56/wKioL1c-bTqD-Op7AACAOxuB4tc693.png "title=" Image.png "alt=" Wkiol1c-btqd-op7aacaoxub4tc693.png "/>

Because the Linux system will record all the files in the system in a database file, the second when using Whereis or locate the contents of this database file will be the same, so sometimes you will find the deleted files, and can not find the latest files just created.

    • Find Find [PATH] [option] [action]

Parameters:

1, time-related parameters:-atime,-ctime,-mtime

(1) Access Time (-atime): The last time the user visited the file;

(2) Modification Time (-mtime): The time the file content was last modified.

(3) Change Time (-ctime): The time the file metadata (metadata, such as permissions or ownership) was last changed.

Take-mtime as an example:

-mtime N # is a number, meaning a file that has been changed in "One Day" before N days

-mtime +n: Lists files that have been changed before n days (excluding n days themselves)

-mtime-n: Lists files that have been changed within n days (including n days itself)

-mtime File:file for an existing file, list files that are newer than file

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/59/wKiom1c-bgCAezxpAADKXpp7_j8175.png "style=" float: none; "title=" 1.png "alt=" Wkiom1c-bgcaezxpaadkxpp7_j8175.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/57/wKioL1c-bu2ydqt_AABUdtpjup8989.png "style=" float: none; "title=" 2.png "alt=" Wkiol1c-bu2ydqt_aabudtpjup8989.png "/>

2. Parameters related to user or user group name

(1)-uid-N is a number, is the user's account ID, which is the UID, this UID is recorded in the/etc/passwd inside number corresponding to the account name

(2)-gid N: N is a number, which is the account ID of the user group name, i.e. Gid,gid is recorded in/etc/group.

(3)-user Name:name is the username name, for example: Fucang

(4)-group name: name is the user group name, for example: user

(5)-nouser: The owner of the search file does not exist files in/etc/passwd

(6)-nogroup: all groups looking for files do not exist files in/etc/group

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/59/wKiom1c-bgHzshnMAABC7JpVg6E257.png "style=" float: none; "title=" 3.png "alt=" Wkiom1c-bghzshnmaabc7jpvg6e257.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/59/wKiom1c-bgGjiQeKAABYL2FrVHo912.png "style=" float: none; "title=" 4.png "alt=" Wkiom1c-bggjiqekaabyl2frvho912.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/57/wKioL1c-bu7TshTUAAB15HhLpRs118.png "style=" float: none; "title=" 5.png "alt=" Wkiol1c-bu7tshtuaab15hhlprs118.png "/>

3. Parameters related to file permissions and names

(1)-name filename: Find a file named filename

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/57/wKioL1c-bu_wMPNzAABUk18zhDA050.png "style=" float: none; "title=" 6.png "alt=" Wkiol1c-bu_wmpnzaabuk18zhda050.png "/>

(2)-size [+-]size: Find a file larger than size (+) or small (-).

Size: C: Representative Byte,k: 1024bytes

Eg: find a file larger than 50KB, which is "Find-size +50k"

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/59/wKiom1c-bgOxSX1RAABbznCVR-k609.png "style=" float: none; "title=" 7.png "alt=" Wkiom1c-bgoxsx1raabbzncvr-k609.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/59/wKiom1c-bgODsq2rAAAZzRYHo7s366.png "style=" float: none; "title=" 8.png "alt=" Wkiom1c-bgodsq2raaazzryho7s366.png "/>

(3)-type type: Find the type of file, type, mainly:

General formal documents (f), equipment files (b, c), Table of contents (d),

Connection file (l), socket (s), FIFO (p), etc.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/57/wKioL1c-bvChRuZyAACfX0_kuq0184.png "style=" float: none; "title=" 9.png "alt=" Wkiol1c-bvchruzyaacfx0_kuq0184.png "/>

(4)-perm mode: Find file Permissions "just equals" mode file, mode similar to chmod

Property value, Eg:-rwxr-xr-x's property value is 0755

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/57/wKioL1c-bvHg5aBgAAC0RLYVV2E930.png "style=" float: none; "title=" 10.png "alt=" Wkiol1c-bvhg5abgaac0rlyvv2e930.png "/>

(5)-perm-mode: Find file Permissions "must all include Mode's permission" file

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/59/wKiom1c-bgXiINopAACtcLXeWwY867.png "style=" float: none; "title=" 11.png "alt=" Wkiom1c-bgxiinopaactclxewwy867.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/59/wKiom1c-bgWAp6zkAAAtKIClLJA453.png "style=" float: none; "title=" 12.png "alt=" Wkiom1c-bgwap6zkaaatkicllja453.png "/>

(6)-perm +mode: Find file Permissions "contains any one mode permission" of the file,

eg: when we look for-rwxr-xr-x, which is-perm +755, a file property of-RW-------is also listed because it has-RW ...

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/57/wKioL1c-bvPiIOKUAADS6KMmNF4966.png "style=" float: none; "title=" 13.png "alt=" Wkiol1c-bvpiiokuaads6kmmnf4966.png "/>

4. Other operations

-exec Command:command for other commands,-exec can be followed by other commands . Richard looked for the result

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/59/wKiom1c-bgfTyWJXAADKfSufwGc201.png "style=" float: none; "title=" 14.png "alt=" Wkiom1c-bgftywjxaadkfsufwgc201.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/57/wKioL1c-bvOxJ6DwAAANH4KpAsc419.png "style=" float: none; "title=" 15.png "alt=" Wkiol1c-bvoxj6dwaaanh4kpasc419.png "/>

Put the results found in Find-perm 0664 into {} and ls-l the result

-print: Print results to the screen (this action is the default action)

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/59/wKiom1c-bgeQRSrVAAAki6o6JsY807.png "style=" float: none; "title=" 16.png "alt=" Wkiom1c-bgeqrsrvaaaki6o6jsy807.png "/>


Search for files in Linux Whereis, locate, 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.