Find where executable is installed to

Often when writing a script, I want to put a hashbang (#!) at the top so that I can execute the file, but I can never remember where the binary for python or php is installed to. An easy way to find out is to use the which command:

mark-ubuntu$ which python

Another nice command is whereis which will “locate the binary, source, and manual page files for a command”:

mark-ubuntu$ whereis python
python: /usr/bin/python2.6-config /usr/bin/python2.6 /usr/bin/python /etc/python2.6 /etc/python /usr/lib/python3.1 /usr/lib/python2.6 /usr/local/bin/python2.7-config /usr/local/bin/python2.7 /usr/local/bin/python /usr/local/lib/python2.7 /usr/local/lib/python2.6 /usr/include/python2.6 /usr/share/python /usr/share/man/man1/python.1.gz