To check if packagename was installed:

dpkg -s <packagename>

You can also use dpkg-query that has a neater output for your purpose, and accepts wild cards, too.

dpkg-query -l <packagename>

To find what package owns the command:

dpkg -S `which <command>`

Source: Stack Overflow