Can APT tell me which packages on my system were installed explicitly?

Asked by Jonathan Knowles

I'd like to generate a list of all packages I've explicitly chosen to install on my system.

I'd like this list to include anything I've explicitly chosen to install with apt-get, aptitude, adept or synaptic since installing Ubuntu from CD.

I don't want this list to include dependencies, unless of course I've chosen to install them explicitly at some point. I also don't want to include any previously installed but subsequently removed packages.

Can APT tell me this information?

== Example ==

Let's say I perform the following actions:

1. Install Ubuntu
2. Using apt-get, install "mozilla-thunderbird".
3. Using aptitude, install "mozilla-firefox".
4. Using adept, install "konversation".
5. Using aptitude, remove "mozilla-thunderbird".

After these actions are performed, the list of explicitly installed packages is: [mozilla-firefox, konversation]

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apt Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
andrzejkaminski (andrzejkaminski) said :
#1

You can only see which packages were automatically installed. They are listed in /var/lib/apt/extended_states

Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#2

Why don't use dpgk...?

To save a preselection of installed packages:
sudo dpkg --get-selections > installed.log

To install on another pc all the packages from that saved selection:
sudo su

dpkg --set-selections < ./installed.log && apt-get dselect-upgrade && apt-get autoremove

HTH

Revision history for this message
Andrea Corbellini (andrea.corbellini) said :
#3

apt-get can't do it but you can use deborphan:
  deborphan -a
This will list all packages which were not installed as dependency of an another package, so all packages installed by hand.

Revision history for this message
Asa Ayers (asa-ayers) said :
#4

It seems like deborphan -a mostly answers the question, but is there a way to exclude the packages that were installed as a base install of Ubuntu?

Revision history for this message
Andrea Corbellini (andrea.corbellini) said :
#5

You can use `grep` to exclude them:
  deborphan -a | egrep -v "linux-.*|.*ubuntu-(desktop|minimal|standard)"
If this command is too long, you can create a shortcut in your ~/.bashrc file. To do this, open it and and put a line like this one:
  alias explicity-installed='deborphan -a | egrep -v "linux-.*|.*ubuntu-(desktop|minimal|standard)"'
Of course, you can replace "explicity-installed" with whatever you prefer.

Revision history for this message
Martin Olsson (mnemo) said :
#6

Running the command:
deborphan -a | egrep -v "linux-.*|.*ubuntu-(desktop|minimal|standard)"

On my jaunty system prints stuff I'm absolutely sure I didn't explicitly install, like for example:
libboost-date-time1.34.1

Also it failed to print "gitk" which is I am sure I did explicitly install.

Does anyone know a more accurate method to list all the explicitly installed packages?

Revision history for this message
Pascal R. (niun) said :
#7

I am also interested in such a list. All previous given answers have some problems:

=> dpkg --get-selections:
This gives a list of all installed packages. Right?

=> deborphan -a:
That is cool, but if you've explicitly installed "gitk" like martin, and then install something, that depends on gitk or even only suggests it (like "git-doc"), it doesn't show up in the list.
If you want to use this list, to decide, what to install on another system, it is fine if you want to install all packages. But if you decide that you have read enough about git and don't want to install "git-doc" this time, you will forget "gitk".

=> /var/lib/apt/extended_states:
Ok, you could write a script, that gets all installed packages and remove the packages listed in /var/lib/apt/extended_states. But than there are many packets left that were installed during installation of Ubuntu.

Is there a way to get a list of packages installed during installation? I think it depends on your hardware and language, which packages were installed.
Maybe there is a possibility to run the installation program and before clicking "OK, install like I have selected!" intercept a generated list of packages to be installed?

Revision history for this message
Pascal R. (niun) said :
#8

I am also interested in such a list. All previous given answers have some problems:

=> dpkg --get-selections:
This gives a list of all installed packages. Right?

=> deborphan -a:
That is cool, but if you've explicitly installed "gitk" like martin, and then install something, that depends on gitk or even only suggests it (like "git-doc"), it doesn't show up in the list.
If you want to use this list, to decide, what to install on another system, it is fine if you want to install all packages. But if you decide that you have read enough about git and don't want to install "git-doc" this time, you will forget "gitk".

=> /var/lib/apt/extended_states:
Ok, you could write a script, that gets all installed packages and remove the packages listed in /var/lib/apt/extended_states. But than there are many packets left that were installed during installation of Ubuntu.

Is there a way to get a list of packages installed during installation? I think it depends on your hardware and language, which packages were installed.
Maybe there is a possibility to run the installation program and before clicking "OK, install like I have selected!" intercept a generated list of packages to be installed?

Revision history for this message
Andrea Corbellini (andrea.corbellini) said :
#9

On Sun, 2009-04-26 at 21:04 +0000, martin wrote:
> Running the command:
> deborphan -a | egrep -v "linux-.*|.*ubuntu-(desktop|minimal|standard)"
>
> On my jaunty system prints stuff I'm absolutely sure I didn't explicitly install, like for example:
> libboost-date-time1.34.1

This is because deborphan lists all the installed packages that are not
dependencies of other packages. This means that it doesn't list just the
manually installed packages, but also the unneeded ones. You can safetly
remove libboost-date-time1.34.1 because it is no longer needed.

>
> Also it failed to print "gitk" which is I am sure I did explicitly
> install.

If it doesn't appear, it means that an another package depends on it.

>
> Does anyone know a more accurate method to list all the explicitly
> installed packages?
>

aptitude search ~i | grep -v "i A" | cut -d " " -f 4

This command lists all the packages that are not marked as being
automatically installed. Unfortunately aptitude knows if a package was
automatically installed only if aptitude installed it. This means that
all packages installed with apt-get, Synaptic or with the Ubuntu LiveCD
Installer will be shown.

Can you help with this problem?

Provide an answer of your own, or ask Jonathan Knowles for more information if necessary.

To post a message you must log in.