You can find the directory where a program is installed with the whereis or which command.

If you want to know a program’s full pathname, you can use the whereis program. The whereis program looks in a predefined set of directories for the named program.

% whereis who
who: /usr/bin/who /usr/man/man1/who.1

This tells you that the who program is in /usr/bin. (whereis also tells you where you can find online documentation for the program.)

Although whereis doesn’t tell you about all programs installed on your system, it’s an excellent place to start.

One problem with whereis is that since it looks in a built-in directory path, it may not find programs that are not installed in a “standard” directory. At our office we have many programs installed into /usr/local/txtools/bin, but whereis doesn’t know about them. For example, the rcsgrep command is installed in that directory:

% ls -F /usr/local/txtools/bin/rcsgrep
/usr/local/txtools/bin/rcsgrep*

But whereis can’t find it, because it isn’t in any of the “standard” directories that whereis usually examines:

% whereis rcsgrep
rcsgrep:

A user who can’t run rcsgrep, therefore, has no way to find out where it is installed using whereis. Without knowing where a command is installed, you can’t know what directory to add to your search path .

Get WYNTK: UNIX System Admininistrator now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.