How to view history of apt-get install?

Solution 1:

I think the answer given here by kos is the best way I've seen so far. Though as Software Center uses apt, anything that it has installed would be listed too.

The command is:

zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline: apt-get install (?!.*--reinstall)\K.*'

Solution 2:

Just type following command in your terminal to view all install logs.

grep " install " /var/log/dpkg.log

Solution 3:

To simplify @Arronical answer, A neat trick I learned recently is you can use zcat -qf to cat both txt and txt gzipped files.

zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep " install "

becomes

zcat -qf /var/log/apt/history.log* | grep " install "

From man zcat:

   -q --quiet
          Suppress all warnings.
   -f --force
          Force  compression  or  decompression  even if the file has multiple links or the corre‐
          sponding file already exists, or if the compressed data is read from  or  written  to  a
          terminal.  If  the  input  data is not in a format recognized by gzip, and if the option
          --stdout is also given, copy the input data without change to the standard  output:  let
          zcat  behave  as  cat.  If -f is not given, and when not running in the background, gzip
          prompts to verify whether an existing file should be overwritten.