147

I frequently need to check which packages are installed, and I use the following command:

dpkg -l | grep foo

which gives the following output

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version         Description
ii   foo                       <version>         <description>
  1. What does the ii mean?
  2. What other flags are there?
  3. How to read the flags? (because the explanation is quite complicated, IMO)

Thanks.

4 Answers 4

188

Where to find this information in the system

You can find this information out in the head of dpkg -l output, as it's just a formatting convention:

dpkg -l | head -3

Copied here for reference:

Desired=Unknown/Install/Remove/Purge/Hold                                     
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)                    

Description of each field

As you can see from the first three lines:

First letter → desired package state ("selection state"):

  • u ... unknown
  • i ... install
  • r ... remove/deinstall
  • p ... purge (remove including config files)
  • h ... hold

Second letter → current package state:

  • n ... not-installed
  • i ... installed
  • c ... config-files (only the config files are installed)
  • U ... unpacked
  • F ... half-configured (configuration failed for some reason)
  • h ... half-installed (installation failed for some reason)
  • W ... triggers-awaited (package is waiting for a trigger from another package)
  • t ... triggers-pending (package has been triggered)

Third letter → error state (you normally shouldn't see a third letter, but a space, instead):

  • R ... reinst-required (package broken, reinstallation required)
8
  • 2
    (The vertical bars and slashes in the second, third and fourth line of the header are "arrows" pointing to the first, second and third columns, to help you decipher what htorque has explained in greater depth.) Dec 25, 2010 at 15:03
  • 1
    where can I read this list? I tried man dpkg but it was not there. Jan 9, 2014 at 17:51
  • 1
    @FabrizioRegini Try again, it's right at the top of dpkg's man page (section "INFORMATION ABOUT PACKAGES"). :)
    – htorque
    Jan 13, 2014 at 20:42
  • Where in the dpkg man page does it show the meaning of 'ii', 'if', and so on?
    – pmatulis
    May 28, 2014 at 20:26
  • 2
    @FabrizioRegini Run man dpkg-query.
    – jarno
    May 13, 2017 at 6:40
41

The first letter displays what is the expected status of the package.
The second letter displays what is the current status of the package.

So for example:

  • ii means "It should be installed and it is installed", done with apt install or dpkg -i.
  • rc means "It's removed/uninstalled and its configuration files are still there", done with apt remove or dpkg -r. (Removing a package does not imply removing configuration files.)
  • pn means "It's purged (removed as well as configuration) and it is not installed at all", done with apt purge or dpkg -P.
1
  • 6
    So is it safe to delete the configuration files of the kernel with rc tag?
    – Mars Lee
    Aug 27, 2018 at 20:02
18

Because my rep is low, I cannot comment to answer the questions people have about where to get this info. After reviewing source code for dpkg and related programs' main.c code, I found what I was looking for.

The info for reading the -l | --list output is in

man dpkg-query

and not in

man dpkg

dpkg is merely acting as the front-end in these instances

1
  1. It means that the package is desired to be installed and that the package is installed.

  2. See man dpkg-query

  3. Upper case letters shown in the alternatives after equals sign in the three first lines in the legend are the letters possibly shown shown as the first three characters in the first field, respectively, but not all of them in the same case i.e some of the letters are shown in lower case. The third character is space normally.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .