which vs. whereis vs. dpkg -L

terminalWhile most people using any flavour of Linux must have used which to locate where an executable binary of a command is located, a similar utility whereis may not be so well-known. which looks for a binary within the directories in your $PATH. whereis on the other hand returns you a lot more; it shows you almost everything that came with the command – binary, source code and the man pages location. Quite useful! Example:

$ whereis ls

Now let’s see what dpkg -L can do for Debian packages. You installed a .deb file and you want to know quickly which are the files that got installed with it. Here’s how to do it:

To get the correct name of the package gcstar:

$ dpkg --get-selections|grep gcstar
gcstar                        install

To see which files were installed by this package:

$ dpkg -L gcstar