I was looking through the list of packages with dselect, but pressed Return twice by mistake, thereby making it confirm and quit the [S]elect option.

When I go to the [I]nstall option, it's now suggesting to install a number of new packages that I don't want (and that have nothing to do with what I was looking for in the first place).

Since I haven't proceeded with the installation itself, is there a way to reset the selection to what it was before I selected new packages, without going through the list one by one and pressing - for each package? (It doesn't matter if it's done via dselect or via another related command.)

EDIT: (Adding an example)

I've tried on another machine where dselect is installed. Let's assume that package gnugo isn't installed (that's just an example).

  • Launch delect and choose [S]elect to get the list.
  • Search for gnugo in this list (using /, if you're not familiar with dselect).
  • Select it with +.
  • Press Return to validate the suggestions and Return again to validate go back to the main menu (the mistake I made).
  • Go to [I]nstall. It will now say:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following NEW packages will be installed
      gnugo:i386 libgpm2:i386 libncurses5:i386 libreadline6:i386 libtinfo5:i386
    0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,926 kB of archives.
    After this operation, 9,634 kB of additional disk space will be used.
    Do you want to continue [Y/n]? 
  • Here, choose not to continue (n).

  • Quit dselect.
  • dpkg --get-selections | grep gnugo yields nothing at all.
  • Start dselect again, go straight to [I]nstall again, the packages will still be selected for installation.

Of course, I can go back into the [S]elect list, search for gnugo, press _ to deselect it, but in a more complex case, you may have to go through the new packages list one by one.

[I]nstall in dselect is visibly a front-end to apt-get install, but I'm not sure where it gets its selection from. It appears dpkg --get-selection is not it. As far as dselect is concerned, I'd like to reset it in a state where everything maked with *** stays at it was, but what's now marked with only ** (and not installed yet) goes back to __, without having to go manually through the suggested list from the [I]nstall menu.


This is clearly related to the content of /var/lib/dpkg/status, which contains this entry:

Package: gnugo
Status: install ok not-installed
Priority: optional
Section: games

If I change this manually to Status: deinstall ok not-installed, it disappears from the selection in dselect (which makes sense).

What I would like is a general way of turning whatever says Status: install ok not-installed into Status: deinstall ok not-installed (leaving packages saying Status: install ok installed unaffected).

3 Answers 3


Use the --set-selections* argument to dpkg:

echo "<package-name> purge" | dpkg --set-selections

You can then use apt-get dselect-upgrade to apply your package selection.

If you need to find the packages that have been selected for install but not yet installed (so you can reverse that selection) use this:

dpkg --get-selections | awk '{ if ($2=="install") print $1}' | grep -vF "$(dpkg -l | awk '/^ii/ {print $2}')"

You can get slightly fancier and pipe that back into --set-selections, thereby automatically deselecting anything that's not already installed:

dpkg --get-selections | awk '{ if ($2=="install") print $1,"deinstall"}' | grep -vF "$(dpkg -l | awk '/^ii/ {print $2}')" | dpkg --set-selections

*You can also use dpkg --get-selections to list all of the explicit selections. This will also show you the format that --set-selections requires.

  • I'd like a way not to have to write each package-name. As far as I can see, --get-selections doesn't list those packages that have been marked for installation via dselect but aren't installed yet.
    – Bruno
    Commented Jul 10, 2012 at 19:48
  • @Bruno: I've updated my answer to make it more automatic.
    – bahamat
    Commented Jul 10, 2012 at 23:59
  • Sorry, it doesn't seem to work for me. The dselect selections don't show up at all via dpkg --get-selections. I'm not sure if I explained the problem correctly, but if select with + something with dselect, validate the selection, and then go to the install section, it will say "The following NEW packages will be installed" and a few packages (then asking whether to proceed). If I quit and go back to dselect later to install (or via the select list) they're still suggested, yet they're not at all in the --get-selections list unfortunately. That's the selection I'd like to reset
    – Bruno
    Commented Jul 11, 2012 at 0:05
  • +1, even if it didn't quite work, some of the right elements were there, thanks. I'm still surprised dpkg --get-selections doesn't list those packages. (I'm not sure if it's an issue with this particular version: this is on an Ubuntu 12.04 LTS machine.)
    – Bruno
    Commented Jul 11, 2012 at 1:11
  • Those packages aren't explicitly selected then. Dependancies are never selected (in the dpkg/dselect sense) to be installed. All of those other packages that it's saying will be installed are just dependancies. If you don't want them you'll need to deselect the package that depends on them.
    – bahamat
    Commented Jul 11, 2012 at 1:44

It turns out dpkg --get-selections doesn't list what's marked for installation and not yet installed, but dpkg -l '*' does, and starts these lines with in.

As a result, the following line resets these selections:

dpkg -l '*' | grep '^in ' | awk '{ print $2 " deinstall" }' | dpkg --set-selections

Use Aptitude's search capabilities to obtain the list.

aptitude -F '%p' search '~ainstall !~i'

Pass the list to dpkg --set-selections to mark them as to-be-removed.

aptitude -F '%p deinstall' search '~ainstall !~i' | dpkg --set-selections

Aside: welcome to the 21st century, I suggest switching to Aptitude instead of Dselect.

  • aptitude -F '%p' search '~ainstall !~i' doesn't return anything at all (and gnugo from my example is still marked for installation in `dselect).
    – Bruno
    Commented Jul 11, 2012 at 1:15
  • Interesting... It works on a Debian Lenny and an Ubuntu 10.04 but not on an Ubuntu 12.04... (I think it's time for a move to aptitude anyway :-) )
    – Bruno
    Commented Jul 11, 2012 at 1:35

You must log in to answer this question.

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