Search notes:

dpkg-query

dpkg-query is a command line tool to query the dpkg database.
dpkg-query [option…] command

Commands

Long form Argument
-l --list [package-name-pattern…] See also apt list
-W --show [package-name-pattern…]
-s --status [package-name…] Report status of specified package or display all package entries in the status database. Compare with dpkg -s.
-L --listfiles package-name…
--control-list package-name
--control-show package-name control-file
-c --control-path package-name [control-file]
-S --search filename-search-pattern…
-p --print-avail [package-name…]
-? --help
--version

Options

--admindir=dir
--load-avail
--no-pager
-f, --showformat=format dpkg-query --show -f '${Package} ${Version} ${Section}\n'

Query a package's version

Uh oh, am I affected by CVE-2024-6387?
$ dpkg-query --showformat='${Version}\n' --show openssh-server
1:9.2p1-2+deb12u2

$ dpkg-query --showformat='${Version}\n' --show openssh-client
1:9.2p1-2+deb12u2
Indeed, it seems to be the case.
So, update openssh:
$ sudo apt update
$ sudo apt upgrade openssh-client openssh-server
$ dpkg-query --showformat='${Version}\n' --show openssh-server openssh-client
1:9.2p1-2+deb12u3
1:9.2p1-2+deb12u3

Find packages with a given priority

The following query find package with the package priority important:
$ dpkg-query -W -f='${Package} ${Priority}\n' | grep important | cut -f 1 -d' '
adduser
apt
apt-utils
cpio
cron
debconf
debconf-i18n
debian-archive-keyring
dmidecode
fdisk
gpgv
groff-base
ifupdown
init
iproute2
iputils-ping
isc-dhcp-client
isc-dhcp-common
kmod
less
libbz2-1.0
libcap2-bin
libpcre3
logrotate
man-db
nano
net-tools
netbase
netcat-openbsd
nftables
procps
rsyslog
systemd
systemd-sysv
udev
vim-common
vim-tiny

Index