46

Executing dpkg --get-selections shows packages with one of the markers install or deinstall.

Some packages I could remove completely with apt-get remove.

  1. What does deinstall mean?

  2. What can be done so that the packages marked deinstall are not listed by dpkg --get-selections anymore?

3 Answers 3

22

What does "deinstall" mean?

From the manpage of dpkg this means

the package is selected for de-installation or removal (i.e. we want to remove all files, except configuration files).

You also asked

What can be done so that the packages marked "deinstall" are not listed by "dpkg --get-selections" anymore?

There are two ways you can do for not to be listed in the dpkg --get-selections command.

1. Unselect the packages for removal

You can unselect the packages, which are selected for removal. In this way, dpkg --get-selection will not show "deinstall" entry.

Look at this answer for the exact procedure to do this

2. You can actually do the selected task, i.e deinstall them

It is not recommended, If you have done a dpkg --clear-selections accidentally, which mark all packages as "deinstall" except the essentials one (Here, essentials doesn't mean You can have a system without any unnecessary software, essentials mean, You can only boot and have a very low-level linux system).

The command to do the desired task selected is:

sudo apt-get dselect-upgrade

Hope this will answer your query.


For more information you can check these links.

4
  • 5
    You write "is selected for de-installation or removal (i.e. we want to remove all files, except configuration files)". Well, how did I ("we") select that? Is that what happens when I "apt-get remove ..."? And if so, why are they only "selected for de-installation", why are they not removed instantly when running "apt-get remove"? May 29, 2015 at 12:42
  • You write that it is not recommended to dselect-upgrade. Is that only because, in the case that one has accidentally run --clear-selections, it goes to bare-bone. Or is it for other reasons as well? It seems sort of like an obvious thing to do, to de-install things that are selected for deinstallation :/ ?? May 29, 2015 at 12:45
  • I can't understand the answer either. I am reading the manual, but it's not clear either. For example, the package selection state "install" is described as "The package is selected for installation.". But I find the packages marked as 'install' have all already been installed in my system. What does it mean 'selected for installation'? (when it's already installed?)
    – Chan Kim
    Feb 27, 2019 at 7:27
  • 1
    @MadsSkjern I observe that apt remove does mark certain packages as deinstall in Ubuntu 19.10. I have no idea why it doesn't just remove it immediately. Full example at: stackoverflow.com/a/54239534/895245 Feb 28, 2020 at 8:21
16

The "sudo apt-get dselect-upgrade" answer did not work for me. To remove a single deinstalled package I used:

sudo apt-get --purge remove <package_name>
15

If apt-get --purge fails to remove the package try the following:

Check the de-installed packages to make sure you really want to remove them.

dpkg --get-selections | grep deinstall | cut -f1

If you are sure, execute dpkg --purge:

sudo dpkg --purge `dpkg --get-selections | grep deinstall | cut -f1`
3
  • 3
    Note that this will include any package with "deinstall" in the name. Try dpkg --get-selections | awk '$2 == "deinstall" {print $1}' Aug 2, 2019 at 7:13
  • ... or dpkg --get-selections | awk '$2 == "deinstall" {print $1}' | xargs dpkg --purge
    – Matthieu
    Jul 26, 2021 at 9:24
  • Or just anchor the pattern dpkg --get-selections | grep deinstall$ | cut -f1 | xargs dpkg --purge Oct 6, 2021 at 17:12

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.