How to use whereis command in Linux?

Guanhui
Release: 2020-06-28 15:28:36
Original
4113 people have browsed it

The whereis command in Linux will search for files that meet the conditions in a specific directory. Its syntax is "whereis [-bfmsu]", and its optional parameters include "-b" and "-B", "-s", "-S", "-u".

How to use whereis command in Linux?

The Linux whereis command is used to find files.

This command will search for files that meet the conditions in a specific directory. These files should be raw code, binary files, or help files.

This command can only be used to find binary files, source code files and man pages. Generally, you need to use the locate command to locate files.

whereis Syntax

whereis [-bfmsu][-B <目录>...][-M <目录>...][-S <目录>...][文件...]
Copy after login

whereis Parameter

-b Only search binary files.

-B Only searches for binary files in the set directory.

-f Does not display the path name before the file name.

-m Only search documentation.

-M Only search for description files in the set directory.

-s Only search original code files.

-S Only search the original code files in the set directory.

-u Find files that do not contain the specified type.

whereis Example

Use the command "whereis" to view the location of the command "bash", enter the following command:

$ whereis bash
Copy after login

After the above command is executed, The output information is as follows:

bash:/bin/bash/etc/bash.bashrc/usr/share/man/man1/bash.1.gz
Copy after login

Note: The above output information from left to right is the queried program name, bash path, and bash man manual page path.

If the user needs to query the binary file or help file separately, the following command can be used:

$ whereis -b bash 
$ whereis -m bash
Copy after login

The output information is as follows:

$ whereis -b bash               #显示bash 命令的二进制程序  
bash: /bin/bash /etc/bash.bashrc /usr/share/bash    # bash命令的二进制程序的地址  
$ whereis -m bash               #显示bash 命令的帮助文件  
bash: /usr/share/man/man1/bash.1.gz  #bash命令的帮助文件地址
Copy after login

Recommended tutorial: " PHP》《Linux Operation and Maintenance

The above is the detailed content of How to use whereis command in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template