Previous Table of Contents Next


Module 157
whereis (BSD)

DESCRIPTION

The external whereis command locates the binary, source, and manual page files for a given command. The command names you provide are stripped of the following:

*  any single-character extensions, such as .c, .f, etc.
*  the source code control prefix, s.
*  any pathname preceding the command.

Once the command is preprocessed, whereis searches a set of standard directories for the given command. The directories are:

/bin /usr/hosts
/lbin /usr/local
/lib /usr/include
/llib /usr/lib
/etc /usr/llib
/usr/bin /usr/man/*
/usr/lbin /usr/src
/usr/games /usr/ucb

Some systems search a slightly different set of directories, depending on the directory structure implemented by the vendor.

COMMAND FORMAT

Following is the general format of the whereis command.

    whereis [ -bmsu ] [ -SBM directory -f ] command_list

Options

The following list describes the options and their arguments that may be used to control how whereis functions.

-b Search for only binary files.
-m Search for only manual page files.
-s Search for only source code files.
-u Search for unusual commands. A command is considered unusual if it does not have a file in each requested type (bms). For example, whereis -s -u * displays files located in the current directory that do not have corresponding source code files.
-f Terminates the directory_list. Thus it signals the start of the command_list.
-B directory_list Specifies the directories where whereis searches for binary files for the given commands. This option can be used to change or limit the search path used by whereis.
-M directory_list Specifies the directories where whereis searches for manual page files for the given commands. This option can be used to change or limit the search path used by whereis.
-S directory_list Specifies the directories where whereis searches for source code files for the given commands. This option can be used to change or limit the search path used by whereis.

CAUTION:  
The directory_lists must be composed of complete pathnames. Complete or full pathnames always start with a /. For example, /usr/ucb is a full path, but usr/ucb is not.



Arguments

The following argument may be passed to the whereis command.

command_list The names of commands for which you want entries displayed. Each argument must be a command or file found in one of the specified directories or one of the default directories. The supplied commands are stripped of leading pathnames, trailing extensions, and source code control prefixes.

RELATED COMMANDS

Refer to the find, whatis, whence, which, and man commands described in modules 55, 155, 156, 158 and 87.

RELATED FILES

See the previous table for the list of directories searched by default.

APPLICATIONS

The whereis command is useful for locating where certain files are that have the name of the command or file you specified. For example, if you specified cat as the command argument to whereis, the output would consist of a line for the binary executable, manual page, and, if you have on-line source, the source file.

TYPICAL OPERATION

In this activity you use the whereis command to locate files related to the cat command. Begin at the shell prompt.

1.  Type whereis cat and press Return. After a brief pause the following information is returned.
    cj> whereis cat
    /bin/cat
    /usr/man/man1/cat.1
    /usr/src/cmd/cat.c
2.  Turn to Module 155 to continue the learning sequence.


Previous Table of Contents Next