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 .

One possibility is to find another user who can run rcsgrep to use the which program on it. Like whereis, which tells you the full pathname of a program — but which uses your search path, not just a “standard” directory path. Of course, you can’t use which yourself to find a program that isn’t in your own search path. But if you can find other users who can run the rcsgrep program, they can use which to tell you where the program is installed.

% which rcsgrep
/usr/local/txtools/bin/rcsgrep

This tells me that the rcsgrep program is in /usr/local/txtools/bin. If I add this directory to my search path, I will be able to run the rcsgrep program the next time I log in.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset