Software Center somehow shows quite short list of installed packages. How to get it in text file?
I tried:
> dpkg --get-selections|wc -l
3265
> aptitude search '~i!~M'|wc -l
1181
> dpkg -l | grep ^ii | sed 's_ _\t_g' | cut -f 2|wc -l
3076
> dpkg --get-selections | grep -v deinstall|wc -l
3076
> apt-mark showmanual|wc -l
1181
I know that I've installed few dozens packages, not thousands. I need in the list exactly packages I'd choosen without dependencies to review it.
UPDATE
Many thanks to @kos, I got finally the list with that command:
> zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline: apt-get install \K.*' | tr ' ' '\n' | grep -v '\-\-reinstall'|grep -v '\-\-force-yes'|grep -v '\-y'|grep -v '\-f'|sort|uniq wc -l
103
This doesn't answer the question exactly: it rather gives a command to list all the
apt-get install
commands ever run along with some advices on how to parse the list further in order to get a list of all theapt-get install
command ever run excluding those run by Ubiquity, since the perfect solution for this task seems to not exist.zcat /var/log/apt/history.log.*.gz
: decompresses all the compressedapt
logs in/var/log/apt
, concatenates them and prints tostdout
;cat - /var/log/apt/history.log
: appends/var/log/apt/history.log
and prints tostdout
;grep -Po '^Commandline:(?= apt-get)(?=.* install ) \K.*'
: selects only the lines starting withCommandline: apt-get
containinginstall
with a leading and trailing space and prints the remainder of each selected line tostdout
;This will output the list of all the
apt-get install
commands ever run (the only undesidered output could be anapt-get
-non-install
command mentioning aninstall
package, but that package doesn't exist (yet?), at least in the default repositories);Note: In my installation (Ubuntu 15.04 64-bit), the first four commands listed are those run by Ubiquity during the installation; to exclude these, you may pipe the output to
sed
:So that the final approximate command for Ubuntu 15.04 64-bit would be:
will give you a list of all manually installed packages without the dependencies - the important thing to take note of is that it will also show what package were installed during Ubuntu setup.
To write the output to a file:
There are actually many other ways, such as using this command
Although I have absolutely no idea how the above works ;)
To view packages installed by date:
Packages installed by date use
cat /var/log/dpkg.log | grep "\ install\ > somefile"
Packages installed using
dpkg
usels -l /var/log/dpkg* > somefile
- this one is probably what you're looking for.To view packages installed using dpkg:
This file contains the above information:
/var/log/dpkg.log
This is actually more complicated than it seems, and there are quite a few similar questions on Ask Ubuntu.
I've found that looking in
/var/log/apt/history.log
and the older gzipped versions of that log, any thing installed by anapt-get install
command is listed as installed by that command.So:
Will show you all of them for the period that the current apt history log covers. You'll need to
gunzip
your older logs, and grep those to get all of your information together. The grep commands could all be redirected into a text file to give you a nice list.This is probably only useful for your case if Software Center uses
apt-get install
when installing. I know that Software Center is a front end forapt
but not sure it uses that command explicitly.Here's a slight improvement to the accepted answer that lists the commands with the dates that they were issued on in chronological order. I find the chronological component very helpful if you want to know what you changed when on your system.
The original answer also took only "apt-get install" commands, but apt recently supported direct "apt install" commands which were not captured by the answer. I made the PCRE a bit more lenient to include all apt commands as well.
Here is a Ruby script that uses
rdepends
to check if a package is a dependency for another installed package. That will not tell exactly what you selected, but that does not depend on your log files (which might have been rotated).Installing packages listed as root packages will install all the packages listed in children packages. So you should end up with almost (see drawbacks below) the same packages list.
The children list will shows the packages that are dependencies of other children packages or root packages.
There are some drawbacks with this approach:
apache2
is listed in children packages because I also havelibapache2-mod-php
,libapache2-mpm-itk
andpython-letsencrypt-apache
installed which haveapache2
as a dependency.libapache2-mod-php
andlibapache2-mod-php7.0
). There is a section listing the probable cycle (check the package ancestries for 5 generations), you should include it to have the same list of packages (unless I've overlooked something else).if somebody wants to convert that to Bash or Python, that would be nice since Ruby is less commonly installed on servers than Bash or Python.
This command will give a list of manually installed packages, as well as those where their "automatically installed" reverse dependencies has been removed (for instance, if you remove the ubuntu-server metapackage, its dependencies will no longer be marked automatic, and will now be on this list):
In other words, the above list will return all packages with either no reverse dependencies, or where they are also marked as manually installed.