I am a new Linux and Unix-like system command line user. How do I find and locate the binary, source, and manual page files for a given command?
You need to use the whereiscommand to find the source, binary, and manuals sections for specified commands or files.
|whereis command details|
|Description||Locating command or program|
|Estimated completion time||10m|
- The location of a binary file.
- The location of source code.
- The location of man page.
Find the binary, source code and man page for specified program or command.
The basic syntax is as follows:
whereis [options] program
whereis -BMS directory -f command
To find out the location of the executable, source code and man page for the date command, type:
$ whereis date
Pass the -b option as follows:
$ whereis -b date
Pass the -m option as follows:
$ whereis -m date
Pass the -s option as follows:
$ whereis -s date
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:
$ whereis -m -u *
You can pass the following option to limit limit the places where whereis searches for files:
- -B /path/to/dir : Limit the places where whereis searches for binaries.
- -M /path/to/dir : Limit the places where whereis searches for manual sections.
- -S /path/to/dir : Limit the places where whereis searches for sources.
You must pass the -f option when any of the -B, -M, or -S options are used. The -f option terminate the last directory list and signals the start of file names. In this example, limit search for binary files in /bin/ directory only for ls and gcc commands:
$ whereis -B /bin -f ls gcc
ls: /bin/ls /usr/share/man/man1/ls.1.gz gcc:
There is no output for the gcc command since it is located in /usr/bin/ directory. To find all of the files in the /sbin/ directory that either are not documented in the /usr/man/man8 directory or do not have source in the /root/src directory, enter:
# cd /sbin
# whereis -u -M /usr/man/man8/ -S /root/src/ -f *
From the whereis(1) command man page:
|-f||Define search scope.|
|-b||Search only binaries.|
|-B||Define binaries lookup path.|
|-m||Search only manual paths.|
|-M||Define man lookup path.|
|-s||Search only sources path.|
|-S||Define sources lookup path.|
|-u||Search from unusual enties.|
|-V||Output version information and exit.|
|-h||Display this help and exit.|
Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?