4

Is there a way to find out how a package was installed on Debian?

I.e. see if it was manually installed or which package pulled it as a dependency.

This information should be available somewhere (e.g. for apt-get autoremove to work) but I'm not sure how it can be displayed for individual packages.

2 Answers 2

5

E.g. using Aptitude:

$ aptitude show gimp linux-headers-3.2.0-2-686-pae 
Package: gimp                            
New: yes
State: installed
Automatically installed: no
<snip>

Package: linux-headers-3.2.0-2-686-pae
New: yes
State: installed
Automatically installed: yes
<snip>

This shows two example packages on my system. The "Automatically installed" field shows if it is manually installed or dragged in by a dependency.

This information is available to APT, as you suspect. Depending on which tool you like to use, it will be found in different places, but it will most likely be called "Automatically installed" with a "Yes/No" value.


Info on specific package that dragged in a particular package

You can use apt-rdepends (available in main repositories) to list forwards or backwards dependencies for a package. Example:

$ apt-rdepends -rp --state-follow=Installed \
  --state-show=Installed linux-headers-3.2.0-3-686-pae

Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-3.2.0-3-686-pae
  Reverse Depends: linux-headers-686-pae (3.2+45) [Installed]
linux-headers-686-pae

(The first two lines are a single command, split for readability).

This shows that linux-headers-3.2.0-3-686-pae was dragged in by linux-headers-686-pae, which in turn does not have any reverse dependencies on my system. Look at man apt-rdepends for available switches.


Update: To expand a bit: it is not really useful to know exactly which package A dragged in package B, since package C which also depends on B might have been installed since, and thus removing A should not/will not remove B. apt-rdepends would in this case list that both A and C depend on B, but give no indication whether A or C were originally responsible for the installation of B.

2
  • +1 for being correct for the initial phrasing of the question. But I also want to know which package pulled the package in question as a dependency (see edited question).
    – m000
    Sep 3, 2012 at 11:18
  • @m000: See updated answer about apt-rdepends. Sep 3, 2012 at 11:32
3

Using aptitude I find using its operation why very useful.

For example, I want to find out why I have screen on my system:

$ aptitude why screen
i   byobu Depends screen

But why byobu?

$ aptitude why byobu
Unable to find a reason to install byobu.

byobu was installed manually.

You must log in to answer this question.

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