Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the examples of using whereis command

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "whereis command use examples", in daily operation, I believe many people have doubts about what problems there are in whereis command use examples, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "whereis command use examples" doubts helpful! Next, please follow the small series to learn together!

The whereis command is used to find files. This command looks for files that match the criteria in a specific directory. These files should be source code, binary files, or help files.

Linux whereis command

Here is its format:

whereis [options] [-BMS directory... -f] name...

This is the explanation given on the man page of this command:

whereis can find binaries, source files, and help files for a given command. Found files are displayed with the main pathname removed, and then with the file's (single) tail extension (e.g.: .c) removed, derived from the source-controlled s. Prefixes are also removed. Next, whereis tries to find specific programs in standard Linux locations, as well as in paths specified by and MANPATH.‎

The following examples, presented in Q&A format, give you a sense of how to use the whereis command:

Q1. How to find binary file location with whereis command?

Suppose you want to find, for example, where the command is located. Here is your specific action:

whereis whereis

Note that the first path of the output is the result you want. Use the whereis command, which also displays the help page and the source code path. (It appears if it can be found, but not in this case.) So the second path you see in the output is where the help page file is located.‎

Q2. How do you specify whether to search only for binaries, help pages, or source code?

If you want to search only for, say, binary files, you can use the-b command line option. For example:

whereis -b cp

Similarly, -m and-s correspond to help pages and source code, respectively.

Q3. How to limit where the whereis command searches?

By default, whereis looks for files from hard-coded paths defined by matching characters. But you can limit the search with command-line options if you want. For example, if you only want to find binaries in/usr/bin, you can do so with the-B option.‎

whereis -B /usr/bin/ -f cp

Note: Multiple paths can be given in this way. Use the-f option to clearly separate the directory list from the file names to be searched.‎

Similarly, if you want to search only for help files or source code, you can use-M and-S accordingly.

Q4. How do I view the search path for whereis?

There is also an option corresponding to this. Just add-l after whereis.‎

whereis -l

Here is a partial output of the example:

Q5. How do I find a command with an exception entry?

For the whereis command, a command is considered an exception if it has more than one entry for each explicit request type. For example, commands with no available documents, or commands with documents scattered around, can count as exception commands. When the-u option is used, whereis displays commands with exception entries.‎

For example, the following example shows commands with no document or multiple documents in the current directory.

whereis -m -u * At this point, the study of "whereis command use examples" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report