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.
Command format: which executable file name Common examples: Example one: To confirm that GCC is installed, you can use the following command: which GCC Example two: To view the location path of the CD command, you can use the following command: which CD The command can be one of the following four forms:
is an executable program, just like the files we see in directory/usr/bin. Programs that fall into this category can be compiled into binaries, such as programs written in C and C + +, or programs written in scripting languages, such as Shell,perl,python,ruby, and so on.
is a command built into the shell itself. Bash supports several commands, internally called Shell internal commands (builtins). For example, the CD command in my local environment above is a shell internal command.
is a shell function. These are small-scale shell scripts that are mixed into environment variables. For example, the CD command mentioned above is a shell function in the lab building environment.
is a command alias. We can define our own commands, based on other commands.
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.
Command format: Whereis [Options] File Common parameters: Parameter description
-B Locating the executable file
-M location Help file
-s locating source code files
-U searches the default path for files other than executables, source code files, Help files
-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
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 Example three: Search the path of the GCC source code, you can use the following command: Whereis-s GCC Locate Command
The locate command is similar to the Whereis command, and they use the same database. But the Whereis command can only search the executable file, the online Help file box source code files, if you want more comprehensive search results, you can use the Locate command.
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.
Command format: Locate [Options] [search string] Common parameters: Parameter description
-Q Quiet mode, no error message is displayed
-N display of at most nth outputs
-R using regular expressions to look for conditions
-V Show version message
Common examples: Example one: Search all the files in the ETC directory that begin with SH, you can use the following command: Locate/etc/sh Example two: Search the ETC directory under the file name contains Lou files, you can use the following command: locate/etc/*lou* |