Home » Questions » Computers [ Ask a new question ]

Attain information about installed Ubuntu packages

Attain information about installed Ubuntu packages

What is the best tool that, for any given package, attain the following, if possible, information:

Asked by: Guest | Views: 313
Total answers/comments: 1
Guest [Entry]

"This is a great question. You would think that there would be one nice, handy-dandy tool to tell you such things, but I don't know it. I'll go one by one, and give my best suggestions.


What is the package used for?
When was it installed?
Was this package installed manually
or was it required by another
package?
Are there any packages currently
installed that depends on this
package, i.e. will something break
if it is removed?


On the command line, aptitude show
package or apt-cache show package
will provide a description of the
package, as well as a lot of other
information. Synaptic allows you to
search for an item in various ways,
and it provides a description of the
package. (The descriptions you get
from all these methods are
identical. They all get their
information from the same place in a
.deb, I believe.)
Such a simple thing, but other than
digging through logs, I can't think
of how to do this. Synaptic doesn't
seem to keep this information as
meta-data. (This would make a great
wish-list bug.) Here's one way to do
it:

zgrep package /var/log/dpkg*

That's a bit cludgy, and it will
produce a lot of output, but it
should also get you the date you
want. (You need zgrep since older
logs will be gunzipped archives.) By the way, you need to be root even to search dpkg's logs.
If you run aptitude show package
on an installed package, check the
field ""Automatically installed."" If it says yes, it was brought
in as a dependency of some other
package. (For the record, there are
things you can do to manually change
this setting. That is, you can
mark a package to look manually
installed, even though it was
actually installed as a dependency.
But for the most part, the results
here should be valid.) You can also
filter Synaptic searches to look for
things installed as dependencies.
A brute-force way to check this:

aptitude -s remove package

The -s flag simulates commands.
You can run such a command as a
regular user, and there's no danger
of actually harming your system. It
allows you to see easily what the
proposed action would do. One thing
to keep in mind is that this sort of
check will show you gross
breakage, but it won't show broader
mistakes. What I mean is you might
be able to remove package Foo
without truly breaking your system,
but it may severely limit the
usefulness of package Bar. In
general, packages are chained
together through recommendations to
prevent just this, but it's worth
keeping in mind. You can also search for dependencies and reverse dependencies using apt-cache, but I find the simulated run is the most vivid way of seeing what will happen.

One other general search tip for Aptitude. On the command line, you can use these searches to quickly see what you have installed by choice versus what was installed automatically as a dependency of something else:

aptitude search '~i !~M' # Find things not installed as something else's dependency
aptitude search '~i ~M' # Find things installed as something else's dependency"