which
From NetBSD Wiki
The which(1) command takes one or more command names as arguments. For each command, it searches the PATH environment variable for the program it corresponds to. The result is written on the standard output stream.
% which ls /bin/ls
Known problems
This command is implemented as a stand-alone program in NetBSD. In older versions of NetBSD and some OSes, it is a csh-script. This means that the command's result may be different from what your current shell sees.
In Bourne-compatible shells (sh and ksh from base, and many others) you can use the type builtin to see the type of a command. The command can be a shell built-in, alias, shell function, or a binary. It will also show you what it is aliased to or which binary it finds in $PATH. This is to be preferred over using which(1), because a built-in can see aliases or functions defined in the current shell.
In other shell/OS combinations, you may also find the builtins or executables whence (ksh, zsh at least) or where (zsh), which will do roughly the same thing.
The C shell (csh) has no built-in equivalent for which(1).
Here is an example of the problems with which:
$ sh
$ type type
type is a shell built-in
$ type which
which is a tracked alias for /usr/bin/which
$ which type
$ which which
/usr/bin/which
$ which foo
$ type foo
foo: not found
$ foo() {
> ls
> }
$ which foo
$ type foo
foo is a shell function
$ alias foo=ls
$ which foo
$ type foo
foo is an alias for
ls
$
As you can see, of the four different types of commands, which(1) can only see one: real files in $PATH, while type can see them all. csh users are just out of luck when they want to distinguish between a shell built-in, a function or an alias...
