whereis と which

estis2017/03/16 (木) 10:32 に投稿
$ whereis openssl
/usr/bin/openssl
$ which openssl
/usr/local/opt/openssl/bin/openssl

の違いは、

$ echo $PATH
/usr/local/opt/openssl/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/local/opt/ruby/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/share/dotnet

だからで、

$ man whereis

WHEREIS(1)                BSD General Commands Manual               WHEREIS(1)

NAME
     whereis -- locate programs

SYNOPSIS
     whereis [program ...]

DESCRIPTION
     The whereis utility checks the standard binary directories for the specified programs, printing out the paths of any it finds.

     The path searched is the string returned by the sysctl(8) utility for the ``user.cs_path'' string.

SEE ALSO
     find(1), locate(1), man(1), which(1), sysctl(8)

COMPATIBILITY
     The historic flags and arguments for the whereis utility are no longer available in this version.

HISTORY
     The whereis command appeared in 3.0BSD.

BSD                             April 27, 1995                             BSD

$ man which

WHICH(1)                  BSD General Commands Manual                 WHICH(1)

NAME
     which -- locate a program file in the user's path

SYNOPSIS
     which [-as] program ...

DESCRIPTION
     The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.

     The following options are available:

     -a      List all instances of executables found (instead of just the first one of each).

     -s      No output, just return 0 if any of the executables are found, or 1 if none are found.

     Some shells may provide a builtin which command which is similar or identical to this utility.  Consult the builtin(1) manual page.

SEE ALSO
     builtin(1), csh(1), find(1), locate(1), whereis(1)

HISTORY
     The which command first appeared in FreeBSD 2.1.

AUTHORS
     The which utility was originally written in Perl and was contributed by Wolfram Schneider .  The current version of which was rewritten in C by Daniel Papasian .

BSD                              June 21, 2002                             BSD

の違いによる。