3 examples for dpkg-query
# list installed packages wit "foo" in name with status/arch/version/description
dpkg-query -l '*foo*'
# The Parameter "-S" "searchs for packages that own files
# corresponding to the given pattern."
#
# "$(which fmt)" is a way to ask for the complete path to fmt
# and may be resolved to "/usr/bin/fmt".
#
# Find the package which owns the already installed program "fmt":
dpkg-query -S "$(which fmt)"