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

How to use the whereis command to find files under linux system

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how to use the whereis command to find files on the linux system. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Instruction name: whereis

Function description: find files that meet the criteria in a specific directory. The intensity of these files should belong to the original code, binaries, or help files.

Syntax format: whereis [- bfmsu] [- B...] [- M...] [- S...] [file.]

Description of common parameters:

-b looks for only binaries.

-B only looks for binaries in the set directory.

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

-m only looks for description files.

-M only looks for description files in the set directory.

-s only looks for the original code file.

-S only looks for the original code file in the set directory.

-u looks for files that do not contain the specified type.

The whereis command can only be used to search for program names, and only binary files (parameter-b), man description files (parameter-m), and source code files (parameter-s) are searched. If the parameter is omitted, all information is returned.

Compared with find, whereis search is very fast, this is because the linux system will record all the files in the system in a database file, when using whereis and the following locate, it will look for data from the database, instead of traversing the hard disk to find, as the find command does, it will naturally be very efficient.

However, the database file is not updated in real time, and by default it is updated once a week, so when we look for files with whereis and locate, we sometimes find the data that has been deleted, or the file has just been created, but cannot find it, because the database file has not been updated.

1. Command format:

Whereis [- bmsu] [BMS directory name-f] file name

2. Command function:

The whereis command locates the location of executable files, source code files, and help files in the file system. The properties of these files should belong to the original code, binaries, or help files. Whereis programs also have the ability to search source code, specify alternate search paths, and search for unusual items.

3. Command parameters:

-b locate the executable file.

-m locate the help file.

-s locate the source code file.

-u search for files under the default path other than executable files, source code files, and help files.

-B specifies the path to search for executable files.

-M specifies the path to search for help files.

-S specifies the path to search for source code files.

4. Use an example:

Example 1: find out all the files related to * * files

Command:

Whereis svn

Output:

The code is as follows:

[root@localhost ~] # whereis tomcat

Tomcat:

[root@localhost ~] # whereis svn

Svn: / usr/bin/svn / usr/local/svn / usr/share/man/man1/svn.1.gz

Description:

Tomcat was not installed and could not be found. Svn installation found a lot of related files.

Example 2: only look up the binaries

Command:

Whereis-b svn

Output:

The code is as follows:

[root@localhost] # whereis-b svn

Svn: / usr/bin/svn / usr/local/svn

[root@localhost] # whereis-m svn

Svn: / usr/share/man/man1/svn.1.gz

[root@localhost] # whereis-s svn

Svn:

[root@localhost ~] #

Description:

Whereis-m svn finds the path to the instruction document, and whereis-s svn looks for the source source file.

Thank you for reading! This is the end of the article on "how to use the whereis command to find files under the linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

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

Servers

Wechat

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

12
Report