Document and content processing - whereis, locate
1. whereis: Find a binary command, press the PATH environment variable to find the path
Whereis command function description
whereis
Command is used to locate the file. This instruction will find qualified files in a specific directory. These documents should belong to the original code, binary files, or help file. This command can only be used to find binary files, source code files andman
manual pages, locate the file in general need to uselocate
the command.Whereis command syntax
whereis
[Options] [-BMS Directory ... -f] name ...whereis
[-bfmsu] [- B <directory> ...] [- M <directory> ...] [- S <directory> ... ][file...]whereis common parameters command Description:
whereis
Small parameters in Table 1 for thewhereis
parameters and descriptions of commands:Table 1:
whereis
Parameters and descriptions of commands
Parameter options | explain |
---|---|
-b | Find only binary files. |
-B <directory> | Find only binary files in the directory settings. |
-f | Does not display the name of the path before the file name. |
-m | Finding just the documentation. |
-M <catalog> | Only to find documentation in the directory settings. |
-s | Only to find the original code files. |
-S <catalog> | Only to find the original code files in the directory settings. |
-u | Find does not contain the specified type of file. |
Whereis command of practical operation
Example 1: using the instruction
whereis
to view the commandcp
position, the following command input
[root@m01 ~]# whereis cp
cp: /usr/bin/cp /usr/share/man/man1/cp.1.gz
Note: The above information is output from left to right as the program name query
cp
path,cp
theman
man page pathExample 2: separate inquiry binary file or help file, use the command
[root@m01 ~]# whereis -b cp
cp: /usr/bin/cp
[root@m01 ~]# whereis -m cp
cp: /usr/share/man/man1/cp.1.gz
2. locate: Find command from the label database (/var/lib/mlocate/mlocate.db), update the library using updatedb
Function locate command Description
locate
Command is used to find qualified document, he will go to save a database file and directory names, find the document or template style directory in line with the conditions. Normally we only need to enterlocate your_file_name
to find the specified file. CentOS 7 This command has no need to manually install, method:yum install -y mlocate
Locate command syntax
locate
[--version]locate
[-d] [- Help] [- Version] [template styles ...]Description of common parameters locate command:
locate
Small parameters in Table 1 for thelocate
parameters and descriptions of commands:Table 1:
locate
Parameters and descriptions of commands
Parameter options | explain |
---|---|
-d or --database = | Locate configuration database used by the instruction. locate command default database located in / var / lib / slocate directory, document named slocate.db, you can use this parameter specify otherwise. |
--help | Online help. |
--version | Displays version information. |
Hands-locate command
Example 1: Find
passwd
the file, enter the following command
locate passwd
Additional information
locate
andfind
different:find
are hard to find,locate
only/var/lib/slocate
to find the library.locate
Faster thanfind
fast, it does not really look, but check the database, the database file in general/var/lib/slocate/slocate.db
, the solocate
lookup is not real-time, but subject to update the database, usually maintain their own system, you can also manually upgrade database, the command islocate -u
Today I write to you, have any questions or something goes wrong, feel free to enlighten the great God who comment