112

For a specific package, can I find out why it is installed?

So, can I see or it's manually installed, or that it is installed as a dependency of another package? Or that it is installed as part of the distro?

107

A quick solution is to enter the following command in a terminal:

aptitude why $package

or, if you are only interested in the ultimate cause:

aptitude why $package --show-summary

Replace $package with the package's name, and you may need to install the aptitude package first.

Here is output you might get for aptitude why aspell --show-summary

Packages requiring aspell:
  inkscape

For more detail you would run aptitude why aspell. You can read the example output, below, as follows: "You manually installed inkscape, which requires libgtkspell, which requires libenchantic2a, which requires aspell". (i markers indicate installed packages; A markers indicate automatically installed packages.)

i   inkscape       Depends libgtkspell0 (>= 2.0.10)                                                                    
i A libgtkspell0   Depends libenchant1c2a (>= 1.6.0)                                                                   
i A libenchant1c2a Depends aspell-en | myspell-dictionary | aspell-dictionary | ispell-dictionary | hunspell-dictionary
i A aspell-en      Depends aspell (>= 0.60.3-2)

Finally, the following command

apt-cache rdepends --installed $package

lists the other packages installed on your computer that depend directly on $package. You can add the --recurse option to list all packages that depend directly or indirectly on it.

  • Pity aptitude isn't included by default :( – badp Oct 10 '10 at 14:21
  • 1
    @badp thank you to point out. This is the bad new with maverick, only to save some space on the livecd iso image. But it is an invaluable tool, and i will not go without. – enzotib Oct 10 '10 at 14:31
  • 15
    apt-cache rdepends --recurse $package probably gives too many packages. I would add --installed option to restrict to installed packages. -i option restricts to pre-dependence and dependence related packages. But a package may be installed because it is recommended by another package. To include such recommendation relateded packages, I suppose this would give the right ones: apt-cache rdepends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances --installed --recurse $package – jarno Dec 22 '13 at 18:20
  • 4
    slightly shorter equivalent of @jarno's incantation, assuming you're on bash or other shell with brace expansion: apt-cache rdepends --no-{suggests,conflicts,breaks,replaces,enhances} --installed --recurse $package – akavel Nov 2 '15 at 10:59
30

A quick and short reasoning on why a certain package was installed can be found out by typing the following command in a terminal (Applications -> Accessories -> Terminal) :

aptitude why <package-name>

Replace with the name of the package you are interested in. For example, typing aptitude why libgoo-canvas-perl outputs the following :

i   shutter Suggests libgoo-canvas-perl

This basically means that the package shutter in this case has suggested libgoo-canvas-perl be installed. By then typing aptitude why shutter I can walk up the dependency chain.

However, there is a caveat. I often notice aptitude finds the most plausible explanation for the situation that may not be the actual case, but will nevertheless give you a clue to look further.

In my case, shutter suggests libgoo-canvas-perl - however, suggested packages are not automatically installed by default. Nevertheless, it jogs my memory of the "experience" with not being able to edit screenshots with shutter which led me to manually install ligbgoo-canvas-perl

Finally, you can find out whether a package was installed automatically (meaning decided by the package management system as mandatory from looking at dependencies and recommendations of other packages you asked it to install) by running following command.

aptitude show <package-name>

This will output a line like below (3rd line of the output) :

Automatically installed: no

For more info run info aptitude (in a terminal) or visit the Aptitude wiki page

To find out when a particular package was installed, there are 2 options:

  1. Synaptic package manager maintains a history log of all activity. To view the history log file, choose History from the File menu. You can search for Install (mind the case) to list all entries regarding installation. However, this will only show the packages installed using Synaptic
  2. Run the following command in a terminal. This will search dpkg logs for installation history entries. However, there is maximum limit of how much of these logs are retained, so if the package you are looking for was installed a long time ago, you may not find it. More details here

    zcat -f /var/log/dpkg.log* | grep "\ install\ " | grep -i <package-name>
    
  • 1
    If you want to find out when a package was installed or upgraded zcat -f /var/log/dpkg.log* | grep -i PackageName | egrep “\ install\ |\ upgrade\ “ – Chris Good Jul 31 '15 at 0:19
  • @ChrisGood: can you re-enter your comment without smart quotes, so it's copy/pastable? – Dan Dascalescu Jan 25 '17 at 16:51
  • 1
    Thanks for pointing that out. With correct double quotes: zcat -f /var/log/dpkg.log* | grep -i PackageName | egrep "\ install\ |\ upgrade\ " – Chris Good Jan 25 '17 at 23:48
12

Yes, you can, and it's a pretty obvious command, in fact. Assuming you've aptitude installed, you can open up a Terminal Window ad type:

aptitude why package

That should give a list of packages that depend on that specific package. If it's a manually installed package, it will say something like "It wasn't possible to find a reason to install package".

5

Here's a simple way that doesn't rely on aptitude, which 10.10 doesn't ship by default anymore.

Graphically

Open Synaptic and try to remove it.

If a dialog pops up asking you to delete other packages, those are the packages that (recursively) depend upon it.

From terminal

apt-get remove package_name_goes_here -s

Again, the packages that would be removed as a result are all those that (recursively) depend on it. (The -s parameter tells apt-get to not actually remove the package.)

  • 2
    This is a risky solution because it could actually remove the package and all dependencies if they mis-click. – ImaginaryRobots Oct 10 '10 at 15:41
  • 1
    @ImaginaryRobots, that's a lot of misclicking. (You have to misclick Ok on the first dialog, then Apply, then again Ok on the confirmation dialog.) For the terminal version, there's also an extra y/N confirmation request should you typo -s. I added a warning however. – badp Oct 10 '10 at 15:44
  • 1
    -1 as this information is availble in Synaptic under the dependencies tab, when viewing the properties of a package. – alexanderpas Oct 29 '10 at 22:46
  • @alex incorrect - that dialog doesn't tell you whether that package is installed manually or automatically. PS: Inbox counter reset, try harder. – badp Oct 29 '10 at 22:52
  • @badp no, but that info can be found with the "Installed (manual)" status filter on the main screen, and can be seen in the package menu when you select a package. – alexanderpas Oct 29 '10 at 23:42

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.