How to get installed/not installed state of **all** packages?

l0b0

I've found a bazillion references to get a list of the installed packages, but how can I print a single list of all known packages with their "package state" (not-installed, installed, half-installed etc. as defined by dpkg) in a shell, ideally like this:

awk   not-installed
bash  installed
cc    half-installed
[...]

dpkg --get-selections and dpkg --list only lists installed packages.

dpkg --get-selections '.' does not work.

apt-cache dump does not print whether packages are installed, and also prints a lot of irrelevant stuff.

I'm using Travis CI, which is running Ubuntu 12.04 LTS Server Edition 64 bit with for example dpkg-query 1.16.1.2.

kos

You want dpkg-query;

For dpkg-query >= 1.17.11:

dpkg-query -f '${Package}\t${db:Status-Status}\n' -W '*'

For dpkg-query < 1.17.11:

dpkg-query -f '${Package} ${Status}\n' -W '*' | awk '{print $1"\t"$4}'

#1:

  • -f '${Package}\t${db:Status-Status}\n': When used with the -W option, specifies the format of the output (see man dpkg-query for other options);
  • -W '*': lists all the packages matching the pattern *;

#2:

  • -f '${Package} ${Status}\n': When used with the -W option, specifies the format of the output (see man dpkg-query for other options);
  • -W '*': lists all the packages matching the pattern *;
  • awk '{print $1"\t"$4}': prints only the first and fourth field;

In this case it seems like you want to list the status word, so I picked the db:Status-Status virtual field; here are the other virtual fields related to the package status:

              db:Status-Abbrev
                     It contains the abbreviated package status, such as  "ii"
                     (since dpkg 1.16.2).

              db:Status-Want
                     It contains the package wanted status, part of the Status
                     field (since dpkg 1.17.11).

              db:Status-Status
                     It contains the package status word, part of  the  Status
                     field (since dpkg 1.17.11).

              db:Status-Eflag
                     It  contains  the  package status error flag, part of the
                     Status field (since dpkg 1.17.11).

user@user-X550CL ~/tmp % dpkg-query -f '${Package}\t${db:status-status}\n' -W '*' | head
aalib1  not-installed
account-plugin-aim  installed
account-plugin-empathy  not-installed
account-plugin-facebook installed
account-plugin-flickr   installed
account-plugin-foursquare   not-installed
account-plugin-gadugadu not-installed
account-plugin-generic-oauth    not-installed
account-plugin-google   installed
account-plugin-groupwise    not-installed

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to get list of all installed packages along with version in composer?

From Dev

How to get namespace of all packages installed in a salesforce organization?

From Dev

How to npm install --save all packages already installed?

From Dev

Get pip install command for all packages installed inside virtualenv

From Dev

How to list licences of all installed packages in Debian-based distros?

From Dev

How to list all the installed packages and their version with Cabal?

From Dev

How to find all the driver packages installed in my pc?

From Dev

How to get the list of installed library packages only?

From Dev

how to uninstall all packages installed by "aptitude build-dep"

From Dev

How to list all installed packages

From Dev

How to Remove all packages which is installed by dpkg from debs

From Dev

How do you remove MacPorts and all the packages it has installed?

From Dev

How do I reinstall all packages installed with Homebrew?

From Dev

How can I uninstall all the packages I've installed today?

From Dev

How to backup all installed software/packages on AIX?

From Dev

How to list all installed packages

From Dev

How can I get a list of all packages available for a specific version of Ubuntu (not necessarily the one I have installed)?

From Dev

how to uninstall all packages installed by "aptitude build-dep"

From Dev

How to get the list of installed library packages only?

From Dev

How to get the list of installed packages without dependencies?

From Dev

How to Remove all packages which is installed by dpkg from debs

From Dev

Get pip install command for all packages installed inside virtualenv

From Dev

How to reinstall all installed packages with zypper

From Dev

How to list all packages installed as dependencies in Terminal, and what installed them?

From Dev

Download all installed packages

From Dev

Wix get the installed state of the packages in custom managed BA

From Dev

How to get all URLs for packages that would be installed for `apt install <pkg>` command

From Dev

How can I mark all packages with installed dependents as "Automatically Installed"?

From Dev

How can I reset installed packages to default state?

Related Related

  1. 1

    How to get list of all installed packages along with version in composer?

  2. 2

    How to get namespace of all packages installed in a salesforce organization?

  3. 3

    How to npm install --save all packages already installed?

  4. 4

    Get pip install command for all packages installed inside virtualenv

  5. 5

    How to list licences of all installed packages in Debian-based distros?

  6. 6

    How to list all the installed packages and their version with Cabal?

  7. 7

    How to find all the driver packages installed in my pc?

  8. 8

    How to get the list of installed library packages only?

  9. 9

    how to uninstall all packages installed by "aptitude build-dep"

  10. 10

    How to list all installed packages

  11. 11

    How to Remove all packages which is installed by dpkg from debs

  12. 12

    How do you remove MacPorts and all the packages it has installed?

  13. 13

    How do I reinstall all packages installed with Homebrew?

  14. 14

    How can I uninstall all the packages I've installed today?

  15. 15

    How to backup all installed software/packages on AIX?

  16. 16

    How to list all installed packages

  17. 17

    How can I get a list of all packages available for a specific version of Ubuntu (not necessarily the one I have installed)?

  18. 18

    how to uninstall all packages installed by "aptitude build-dep"

  19. 19

    How to get the list of installed library packages only?

  20. 20

    How to get the list of installed packages without dependencies?

  21. 21

    How to Remove all packages which is installed by dpkg from debs

  22. 22

    Get pip install command for all packages installed inside virtualenv

  23. 23

    How to reinstall all installed packages with zypper

  24. 24

    How to list all packages installed as dependencies in Terminal, and what installed them?

  25. 25

    Download all installed packages

  26. 26

    Wix get the installed state of the packages in custom managed BA

  27. 27

    How to get all URLs for packages that would be installed for `apt install <pkg>` command

  28. 28

    How can I mark all packages with installed dependents as "Automatically Installed"?

  29. 29

    How can I reset installed packages to default state?

HotTag

Archive