In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the whereis command under linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The function of the command:
Find the binary file location
Find the location of the software's configuration file
Find the source code file location
View the location of the man manual
Grammar
The basic syntax is as follows:
The code is as follows:
Whereis command
OR
The code is as follows:
Whereis program
OR
The code is as follows:
Whereis [options] program
OR
The code is as follows:
Whereis-BMS directory-f command
Examples of whereis usage:
Find the location of the executable file, source code, and man manual for the date command, and enter:
The code is as follows:
$whereis date
The output is as follows:
Animated gif 01: whereis command running on my Debian based server
How to search only the location of binaries?
Use the-b parameter:
The code is as follows:
$whereis-b date
How to search only the location of the man manual?
Use the-m parameter:
The code is as follows:
$whereis-m date
How to search only the location of the source code files?
Use the-s parameter:
The code is as follows:
$whereis-s date
Problem: the whereis-u parameter is problematic. According to man whereis,-u searches for files that do not have binaries or source code files or man manuals. But the actual test found that it had nothing to do with it.
An example from the man manual:
A file is said to be unusual if it does not have one entry of each requested type. Thus the following example, asks for those files in the current directory which have no documentation (means to search for files in the current directory that do not have man documents):
The code is as follows:
$whereis-m-u *
If we cd / bin first and then execute the above command, we will find that the results of whereis-m-u * and where-m * are exactly the same. The function of-u is not realized at all. And it is completely inconsistent with the description of the man document, because the files under the / bin directory all have man documents, according to the meaning of the man document, the result should be empty, but the result is not empty.
How do I limit the search path?
Use the following parameters to restrict the corresponding search path:
-B / path/to/dir: restrict search for binaries in specified directories.
-M / path/to/dir: restrict the search for man manual files in the specified directory.
-S / path/to/dir: restricts the search for binaries in specified directories.
When using any of the-B,-M,-S parameters, you must add the-f parameter, and then specify the file name to search.
The example is as follows: search for ls and gcc only under / bin directory:
The code is as follows:
$whereis-B / bin-f ls gcc
The results are as follows:
The code is as follows:
Ls: / bin/ls / usr/share/man/man1/ls.1.gz
Gcc:
As you can see, gcc's search for binaries in the / bin directory is fruitless, indicating that the binaries for gcc are not in the / bin directory.
Problem: however, I found that although there are no gcc binaries in the / bin directory, there is still output using the above command, not as I translated this article.
Example: this is also an example in the man manual. After testing, the-u parameter is still not consistent with that described in the man manual.
Find all files in the / usr/bin directory whose man documents are not in / usr/man/man1/ and whose source code files are not in / usr/src/, enter:
The code is as follows:
# cd / usr/bin
# whereis-u-ms-M / usr/man/man1-S / usr/src-f *
Test:
The code is as follows:
# cd / bin
# whereis-u-m-M / root-f *
According to the man manual, the function of this command is to find all files under / bin whose man documents are not in / root. So there should be a result output, because there is no man manual for any files in the / root directory. Yes, I was surprised to find that the result was empty.
This is the end of the content of "how to use the whereis command under linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.