Which

From LQWiki
Jump to: navigation, search

The which command tells you where some program is located. This assumes that the program is in your PATH. For example:

$ which ldd
/usr/bin/ldd

Tells you that the ldd command was found in /usr/bin/, which is in your $PATH.

Another example:

$ which source
source: shell built-in command

This simply tells us that source is a built-in command in the shell, that is no real program (it has no binary file on the machine). Another example:

$ which javac
javac:   aliased to /usr/j2sdk1.4.2/bin/javac

This tells us that javac is an alias for (in this case) a binary located in /usr/j2sdk1.4.2/bin/javac.