I want to find a list of all packages with the Priority: field set to Required. These are packages that are normally installed on every system, however I've recently discovered that they aren't necessarily installed for foreign architectures using multiarch. What's the best way to find these packages?


With aptitude you can do that type of search.

aptitude search '?priority(required)'

Note that aptitude is no longer installed by default on newer Ubuntu releases, and its man-page is incomplete; you'll find the full documentation as /usr/share/doc/aptitude/README

  • 1
    If you need to limit your options to software that is in the default install, I think the only option is the following geekery (or something similar to it): mawk '/^Architecture: / { arch = $2; } /^Package: / { package = $2; } /^Priority: required/ { print package " (" arch ")"; }' < /var/lib/dpkg/status – taneli Mar 9 '12 at 16:55
  • 1
    A shortcut to this is aptitude search '~prequired'. For most ?xxxxxxx() in aptitude there is a short ~x version. – thomasrutter Oct 16 '17 at 22:26

(Disclaimer: this answer uses a low level system tool to solve the requested problem, not aptitude. But since aptitude relies on dpkg services, it might still be useful.)

You can make use of dpkg-query combined with grep:

dpkg-query -W --showformat='${Package}\t${Priority}\n' | grep "required$"
  • dpkg-query lists all packages, when no package name is specified.
  • The -W or (--show) allows for listing packages using a specified output format.
  • The output format is provided by the --showformat='formatstring' syntax. The string consists of:
    • ${Package} to display the package name.
    • \t to display a Tab character as field separator.
    • ${Priority} to display the package priority.
    • \n to display a newline character at the end of each line.

Since a sample output without grep looks like this:

klibc-utils required
kmod    required
krb5-locales    standard
lame    optional
landscape-client-ui-install optional
language-pack-en    optional

The grep command displays only lines containing the „required” word at the end, i.e. the packages with Priority: required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.