Learn a Linux command every day (52): where is

Time:2021-9-10

Learn a Linux command every day (52): where is

Yesterday’s recommendation:Learn a Linux command every day (51): which

Command introduction

The whereis command looks for binary programs, code, and other related file paths.

However, compared with find, the speed of where is search is very fast, because Linux will record all the files in the system in one database file. When users use the where is command, it will directly search from the database file. The find command is to traverse the hard disk to find, so it is less efficient than the whereis command.

Syntax format

whereis [ OPTIONS ] file name...

Option description

-b   # Find binaries only
-B < table of contents >   # Find binaries only in the specified directory
-f   # The path name before the file name is not displayed
-m   # Find document only
-M < table of contents >   # Find the document only in the specified directory
-s   # Find only original code files
-S < table of contents >   # Only find the original code file in the specified directory
-u   # Finds files that do not contain the specified type

Application examples

#Find all relevant files
[[email protected] ~]# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[[email protected] ~]# whereis top
top: /usr/bin/top /usr/share/man/man1/top.1.gz
#Only binary files are found
[[email protected] ~]# whereis -b ifconfig
ifconfig: /usr/sbin/ifconfig
[[email protected] ~]# whereis -b top
top: /usr/bin/top

For the related find command, see:Learn a Linux command every day (20): find

Learn a Linux command every day (49): Free

Learn a Linux command every day (50): Date