Ubuntu – What does “selecting previously deselected package” mean


Whenever I install software from the command-line using apt-get or aptitude, I see messages like this:

Selecting previously deselected package foobar-cil-dev.

I understand "downloading" and "setting up", but what does "selecting" mean? And what does it mean that the package was "previously deselected"?

Best Answer

Ubuntu comes with a default set of packages installed and the package manager track those packages. If you remove a package that is installed by default, it becomes marked as "deselected". This means it was installed previously, but has been removed. In fact any package that you install and then remove becomes marked as "deselected".

This is useful for example to replicate the same packages you have on another machine or after a clean install. You can generate a list of "selected" and "deselected" packages on your system using the package manager and then load this list on another machine, which will make the package manager on it to install all "selected" and uninstall the ones marked as "deselected".

To replicate your packages selection on another machine (or restore it if re-installing), you can run this:

dpkg --get-selections > ~/my-packages

Then move the file "my-packages" to the other machine, and there run:

sudo dpkg --set-selections < my-packages && sudo apt-get dselect-upgrade

When you run the command above, all packages that were marked as "selected" will be installed in a batch and all packages marked as "deselected" will be removed, if present. This is a very handy feature.

Related Question