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 argument is omitted, all information is returned.

Compared to Find, Whereis is extremely fast because Linux records all the files on the system in a database file. When using Whereis and locate, which we’ll cover next, it looks up data from the database, rather than traversing the hard drive like find. Efficiency will naturally be high.

However, the database file is not updated in real time. By default, it is updated once a week, so when we look for a file with Whereis and Locate, we sometimes find data that has been deleted, or when we just created the file, we can’t find it because the database file hasn’t been updated.

The command format

Whereis [parameter]... The file name

Command function

The whereis command locates executables, source code files, and help files in the file system. The attributes of these files should belong to the source code, binary files, or help files. The whereis program also has the ability to search source code, specify alternate search paths, and search for unusual items.

The command parameter

  • -b Locates the executable file.
  • -m Locate help files.
  • -s Locates the source code file.
  • -u Searches for all files except executable files, source files, and help files in the default path.
  • -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.

To find outlsCommand location and help location

> whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
Copy the code

According tolsThe binary of the command

> whereis -b ls
ls: /usr/bin/ls
Copy the code

According tolsCommand help documentation

> whereis -m ls

Copy the code

Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station