When I run dpkg -l, I get a list of installed packages, and I'm comparing that to a "model" system that I'm attempting to reproduce. There are several packages appearing in that list, for example emacs23, that I wish to remove. When I run apt-get remove emacs23, however, I'm told that the emacs23 package isn't installed:

# apt-get -y remove emacs23
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package emacs23 is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 97 not upgraded.

Running apt-get update did not help:

Updated information:

# dpkg -l emacs23
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
rc  emacs23        23.3+1-1ubuntu The GNU Emacs editor (with GTK+ user interfa

# apt-cache policy emacs23
  Installed: (none)
  Candidate: 23.3+1-1ubuntu9.2
  Version table:
     23.3+1-1ubuntu9.2 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     23.3+1-1ubuntu9.1 0
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
     23.3+1-1ubuntu9 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

# dpkg -l | grep emacs23
rc  emacs23                          23.3+1-1ubuntu9.2                   The GNU Emacs editor (with GTK+ user interface)

How do I resolve this apparent confusion?

  • Please add the output of dpkg -l emacs23 to your question. – Florian Diesch Oct 13 '15 at 12:58
  • open terminal and run apt-cache policy emacs23 add output to Q – Ravan Oct 13 '15 at 12:59
  • dpkg -l emacs23 and apt-cache policy emacs23 output added. – John Oct 13 '15 at 13:02
  • emacs23 not there...what is your exact Q.... – Ravan Oct 13 '15 at 13:07
  • emacs23 shows up in dpkg -l. The system thinks it is there. How do I get ti to not show up in dpkg -l ? – John Oct 13 '15 at 13:10

From man dpkg:

   -l, --list [package-name-pattern...]
          List  packages  matching given pattern. If no package-name-pattern is given, list all packages in /var/lib/dpkg/status, excluding the
          ones marked as not-installed (i.e. those which have been previously purged).

This means that dpkg-l lists all the non-purged packages, and not all the installed packages;

In fact, from man dpkg-query (to which dpkg -l acts as a front-end):

          Desired action:
            u = Unknown
            i = Install
            h = Hold
            r = Remove
            p = Purge

          Package status:
            n = Not-installed
            c = Config-files
            H = Half-installed
            U = Unpacked
            F = Half-configured
            W = Triggers-awaiting
            t = Triggers-pending
            i = Installed

Which means that rc at the start of the line means:

  • r: The package's Desired action is: "Remove";
  • c: The package's Status is: only configuration files are present;

Since you want to reproduce an existing system, packages with an rc Desisred action / Status combination that don't appear in the "model" system should be purged:

sudo apt-get purge emacs23

As a side-effect, those packages won't even pop up in dpkg -l anymore.

  • Is there a way to remove the config files and convince the system that emacs23 was never installed in the first place? – John Oct 13 '15 at 14:06
  • @John Sure, if you purge the package it will be gone. sudo apt-get purge emacs23 – kos Oct 13 '15 at 14:11
  • @John Was that actually your question? Initially I read "There are several packages appearing in that list, for example emacs23, that I wish to remove" as "There are several packages appearing in that list, for example emacs23, that I wish to remove from the output list", but after your last question I'm pretty sure you actually meant "There are several packages appearing in that list, for example emacs23, that I wish to remove from the system". – kos Oct 13 '15 at 14:19
  • My goal was "I want the system to think these packages were never installed." I come from the land of Fedora / RHEL, so I'm not completely used to the Debian / Ubuntu way of managing packages yet. – John Oct 13 '15 at 14:21
  • @John Ok now I got exactly what you wanted. Not that it adds something to what we said already here in the comments but I updated my answer to fit the question better anyway. – kos Oct 13 '15 at 14:34

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.