which command
The purpose of the which command is to search for the location of the executable file in the path specified by the PATH variable . It is generally used to verify that the specified software is installed on the system.
(1) command format
which executable file name
(2) Common examples
Example one: to confirm that GCC is installed, you can use the following command:
which GCC
650) this.width=650; "src=" Https://dn-anything-about-doc.qbox.me/linuxcommand/which1.png "alt=" alt text "/>
Whereis command
The Whereis command is primarily used to locate executable files, source code files, and Help files in the file system. The Whereis command also has the ability to search for source code, specify alternate search paths, and search for unusual items.
Whereis command Lookup is very fast, because it is not in the disk for aimlessly scrambling, but in a database (/var/lib/mlocate/) query. This database is created automatically by the Linux system, contains information about all local files, and is updated daily by automating the UpdateDB command. It is precisely because this database is updated every day, it will make the Whereis command search results are sometimes inaccurate, such as the newly added files may not be found.
(1) command format
Whereis [Options] File
(2) Common parameters
Parameters |
Description |
-B |
Locating executable files |
-M |
Locating Help Files |
-S |
Locating source code files |
-U |
Search for files other than executables, source code files, Help files under the default path |
-B |
Specify the path to the search executable file |
-M |
Specify the path to the search Help file |
-S |
Specify the path to the search source code file |
(3) Common examples
Example One: search the path to the GCC executable file, using the following command:
Whereis-b GCC
Example Two: searching the path of the GCC help file, you can use the following command:
Whereis-m GCC
Locate command
The locate command is similar to the Whereis command, and they use the same database. However, the Whereis command searches only for executables, online Help files, and source code files, and you can use the Locate command if you want to get more comprehensive search results.
The locate command uses a very complex matching syntax that allows you to use special characters such as ' * ' and '? ' ) To specify the sample you want to find.
(1) command format
Locate [Options] [search string]
(2) Common parameters
Parameters |
Description |
-Q |
Quiet mode, no error messages are displayed |
-N |
Display up to n outputs |
-R |
Use regular expressions to look for conditions |
-V |
Show version Message |
(3) Common examples
Example One: search all the files in the ETC directory that begin with SH, you can use the following command:
Locate PHP.ini
Note that executing this command will cause an error: Locate cannot execute stat() ‘/var/lib/mlocate/mlocate.db’
: There is no file or directory.
The workaround is to execute the sudo updatedb
command.
This article is from the "My PHP path" blog, so be sure to keep this source http://phpme.blog.51cto.com/663593/1977474
The use of which, Whereis, locate commands in Linux commands.