Linux Location and File Finding Command

linux locate

Syntax

➜  ~ locate patterns

Explain

Linux locate command is used to find eligible documents or directories in the database.

When locate is first executed, it establishes an index database, and when it is executed again later, it quickly locates files from the index database.

Locate is well suited for iteratively searching for directory trees that rarely change, but for renamed old files and newly created files, can't be found unless the database is rebuilt.


PS:
Locate is different from Find: 
Find is to find the hard disk, Locate is only found in the database.

Example

➜  ~ locate php
# More Info
➜  ~ man locate

linux find

Syntax

➜  ~ find path expression [action]

Explain

Using Path as the starting point of the search, each document that meets the expression criteria is found layer by layer, and the action represented by the action is executed on the file.



Example

➜  ~ find /usr -name "php" -type f
#➜  ~ find /usr -name "php" -perm 755

linux which

Syntax

➜  ~ which command

Explain

Find the command location in order from the directory listed in the Path environment variable, and display the name of the full path

Example

➜  ~ which php

linux whereis

Syntax

➜  ~ whereis program

Explain

Find out the executable file, source code file and the path of manpage for a particular program.

Example

➜  ~ whereis php

Add a Comment

Your email address will not be published.