home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Unix Power ToolsUnix Power ToolsSearch this book

2.3. whereis: Finding Where a Command Is Located

The whereis command helps you to locate the executable file, source code, and manual pages for a program. I use it primarily as a sanity check; if I type cat useless.txt and get the message "cat: command not found," I immediately try whereis cat. This gives me a lot of information about what went wrong: someone may have removed cat (Section 12.2) from the system, or my PATH (Section 35.6) environment variable may be set incorrectly, etc.

Output from whereis typically looks like this:

% whereis more
cat: /bin/cat /usr/share/man/man1/cat.1.gz

This says that the executable file is /bin/cat and the manual page is /usr/share/man/man1/cat.1.gz.

whereis has a few options worth mentioning:

-b
Only report the executable name

-m
Only report the location of the manual page

-s
Only search for source files

-u
Only issue a report if any of the requested information (executable, manual page, source) is missing

There are other options for modifying the list of directories through which whereis searches; if you need these, check your manual pages. In addition, the functionality and flags for whereis can differ between versions of Unix. For instance, much of the basic functionality of the command was removed in version 4.4 of FreeBSD as well as Darwin. Again, the manual pages will show you this information.

--ML and SP



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.