Linux basics-5day-Linux file search command-(which/whereis/locate)

Linu the X- file members to find commands - ( Which / whereis / the locate )

1, which command

Description: In the PATH variable specified path, the search position of a system command, and returns a search result first. (Find the location of system commands)

Usage: which [parameter option] [executable file name] 

parameter:

The main parameters

significance

-n

Specify the file name length, the specified length must be greater than or equal to the longest file name in all files

-w

Specify the width of the output result field

-v

View version information

Eg:

[root@test ~]#which pwd #Find the pwd command and display the detailed path

2, whereis command

Description: Locate the location of executable files, source code files, and help files in the file system. (Search program name)

Usage: whereis [parameter option] [program name]

parameter:

parameter

significance

-b

Locate executable file

-m

Locate help (man) file

-s

Locate source code files

-u

Search for files other than executable, source code, and help in the default path

-B/-M/-S

Specify the search executable/help/source code file path

Eg:

[root@test ~]#whereis zabbix #Find all files related to zabbix

3. The locate command

Description: View the file location with the database.

Note : The locate command can quickly find files when searching the database. The database is updated by the updatedb program. Updatedb is periodically created by the cron daemon. If the file found by locate is recently created or has just been renamed, it may not be found. In the default value, updatedb will run once a day, and the set value can be updated by modifying crontab.

locate is used to search for files that meet the conditions. It will go to the database storing file and directory names to find files or directories that meet the template style conditions. You can use special characters (such as "*" or "?") to specify Template style, if the specified template is kcpa*ner, locate will find all files or directories that start with kcpa and end with ner. For example, if the name is kcpartner, if the name of the directory is kcpa_ner, it will list the files or directories in that directory. All files in the directory.

The locate command is similar to the find function of finding files, but locate uses the update program to create an index database for all files and directory data in the hard disk. When you execute loacte, you can directly find the index. The query speed will be faster. The index database is generally It is managed by the operating system, but you can also directly issue an update to force the system to immediately modify the index database.

Usage: locatel [parameter options] [file name]

parameter:

parameter

Features

-e

Excluded from search

-f

Exclude specific file systems

-q

Quiet mode, no error message will be displayed

-n

Display up to n outputs

-O

Specify the database name

-d

Specify the database path

-h

Show auxiliary information

-V

Show program version information

Eg:

[root@test ~]#locate cp #Find all files related to cp
[root@test ~]#locate/etc/va #Find all files beginning with va in the /etc directory

Personal public number:

Picture.png

 

 

 

 


Guess you like

Origin blog.51cto.com/13440764/2576749