Is it possible to get a list of most recently installed packages?

  • Is it possible to get a list of packages that were most recently installed through apt-get?

    Now, if only someone would tell me how to list the *manually installed* packages that *I haven't already removed.* Sigh, Linux.

    @AleksandrDubinsky `apt-mark showmanual | less` doesn't do it?

    @GKFX I meant in the context of recently installed packages.

    @AleksandrDubinsky You'd have to use `comm -12 a b` with `a` a sorted copy of `apt-mark showmanual` and `b` a sorted list from one of the answers below.

    @GKFX I think it would be great if you expand this idea into an answer.

    @AleksandrDubinsky I have done now.

    I installed packages but I'm not sure if all of the ones listed for installation were installed. Does it ever happen that some packages are not installed?

  • Isaiah

    Isaiah Correct answer

    10 years ago

    Command to list recently installed packages that were installed via any method (apt-get, Software Center et al.):

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

    Example output:

    2010-12-08 15:48:14 install python-testtools <none> 0.9.2-1
    2010-12-08 15:48:16 install quickly-widgets <none> 10.09
    2010-12-08 22:21:31 install libobasis3.3-sdk <none> 3.3.0-17
    2010-12-09 12:00:24 install mc <none> 3:4.7.0.6-1
    2010-12-09 23:32:06 install oggconvert <none> 0.3.3-1ubuntu1
    2010-12-09 23:34:50 install mpg123 <none> 1.12.1-3ubuntu1
    2010-12-09 23:34:52 install dir2ogg <none> 0.11.8-1
    2010-12-09 23:34:53 install faad <none> 2.7-4
    2010-12-09 23:34:54 install wavpack <none> 4.60.1-1
    2010-12-10 11:53:00 install playonlinux <none> 3.8.6
    

    You could run this command to list only the recently installed package names,

    awk '$3~/^install$/ {print $4;}' /var/log/dpkg.log
    

    Command to list history of apt-get (NOTE: this doesn't list dependencies installed, it simply lists previous apt-get commands that were run):

    grep " install " /var/log/apt/history.log
    

    Example output:

    Commandline: apt-get install libindicate-doc
    Commandline: apt-get install googlecl
    Commandline: apt-get --reinstall install ttf-mscorefonts-installer
    Commandline: apt-get install valac libvala-0.10-dev
    Commandline: apt-get install libgtksourceview-dev
    Commandline: apt-get install python-sphinx
    Commandline: apt-get install python-epydoc
    Commandline: apt-get install quickly-widgets
    Commandline: apt-get install libreoffice3* libobasis3.3*
    Commandline: apt-get install mc
    

    the problem with synaptic is that it doesn't show what you do with aptitude, apt-get and dpkg, for this reason +1 for this option

    This command will not show updates. Use the software center to see everything.

    It might be better to to save a text file like this `cat /var/log/apt/history.log | grep "\ install\ " > install.log`

    `grep " install " /var/log/dpkg.log` will suffice. There's no need to use `cat`. See also this.

    note that this seems only to find packages which were newly installed. Packages for which a new version was installed appear as `upgrade` in `dpkg.log`

    This is great, I used it with the "remove" string to get a list of recently unistalled packages!

    "installed" seems to show both upgraded and installed.

    Why does this only show packages from the last two weeks?

    @AleksandrDubinsky there is log rotate in some cases. So older log may be "dpkg.log.1" and even older are compressed into "dpkg.2.gz". Here is a better version of this answer using zgrep to quickly look inside `.gz` compressed log then order the output oldest to newest:`zgrep -sh . /var/log/dpkg.log{.[0-9]{.gz,},} | awk '$3~/^install$/ {print $1" "$2" "$4;}'`

    And a better version: `zgrep " install " /var/log/dpkg.log*`

    doesn't return anything for me, do you have idea why (it isn't that I didn't installed anything of course ;))

  • Ubuntu's Software Center shows whole history of all packages that were installed/upgraded/removed. Just click "History" at the bottom of the list at left.

    This history button is now at the top of the GUI and can show installed packages and updates. This should be the accepted answer to the question as its the only answer that works for updates.

    This question does not specify a desktop (GUI) environment, but the accepted answer is valid in both GUI and non-GUI scenarios.

    @HDave Definitely not true, `dpkg.log` logs updates.

  • To see also older packages sorted by time of installation:

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

    And for packages installed very long time ago:

    gunzip -c `ls -tr /var/log/dpkg.log.*.gz` | grep " install "
    

    I found a package that's installed 2 days ago in `/var/log/dpkg.log`, but not in `/var/log/apt/history.log`. Still don't know why...

  • All on one line; for command use

    Select and print only the recently installed package-names, all on one line.

    To do so, change the most-voted answer to:

    cat /var/log/dpkg.log |awk '/ install / {printf "%s ",$4}'
    

    This results in a single line of package names. Such a line can easily be added to a sudo apt-get purge command.

    Example output

    libgnome-media-profiles-3.0-0 gstreamer0.10-gconf gnome-media gnome-menus librest-0.7-0 libgoa-1.0-common libgoa-1.0-0 libwacom-common libwacom2 ubuntu-docs apg libgnome-control-center1 libgnomekbd-common libgnomekbd7 gnome-control-center-data gnome-icon-theme-symbolic gnome-settings-daemon ubuntu-system-service gnome-control-center gnome-online-accounts gnome-session-bin indicator-power mousetweaks
    

    Listing packages one below another

    By popular demand, here is slightly adapted version for listing the packages one below another:

    cat /var/log/dpkg.log |awk '/ install / {printf "%s\n",$4}'
    

    Don't parse the output of `cat` command. And how about this `awk '$3~/^install$/ {print $4;}' /var/log/dpkg.log`?

    @AvinashRaj Your `awk` command prints the packages one **below** another; mine one **next** another. That is why an output example might be useful from time to time.

  • The following trick answers Aleksandr Dubinsky's request to limit this to manually-installed packages:

    comm -12 <(apt-mark showmanual | sort) <(grep " install " /var/log/dpkg.log | cut -d " " -sf4 | grep -o "^[^:]*" | sort)
    
    • comm -12 lists lines common to two sorted files.
    • <(command) expands to the name of a file containing the output of command.
    • apt-mark showmanual lists manually installed packages; ie. those that should never be auto-removed.
    • grep " install " /var/log/dpkg.log is taken from the accepted answer.

    An alternative, showing more information, in chronological order, and accessing all available logs, is:

    zcat -f /var/log/dpkg.log* | grep " install " | sort > /tmp/dpkg.log
    grep -F "`comm -12 <(apt-mark showmanual | sort) <(cat /tmp/dpkg.log | cut -d " " -sf4 | grep -o "^[^:]*" | sort)`" /tmp/dpkg.log | grep \<none\>
    

    grep \<none\> limits results to new installations. You could, for example, use grep to limit the search to a three-month period by adding grep 2016-0[567] to the first pipeline; it's very flexible.

    This is getting closer. Things that could be improved: 1) show the packages in chronological order, 2) show more details like install date/times, the version, maybe even the size 3) show all packages installed since the OS was installed.

    Amazing! Do you mind if I clean up your answer to be more concise with more explanations about each command?

    @AleksandrDubinsky Thanks for that edit; I've corrected the description so that it matches the changes you made.

    Do you mind if I remove the "following trick answers Aleksandr Dubinsky's request" noise, the first command which isn't useful, put a good heading, put the main command on top, add sample output, and try to describe all of the commands involved?

    What do you mean by "grep \ limits results to new installations"? It does not seem to affect the output (confirmed with `grep -v \`).

    @AleksandrDubinsky Feel free. And you are absolutely right regarding `grep \`; I was confused regarding how upgrades are logged. (I thought they were listed as `... install ... v1 v2` but they're not.) Well spotted.

    There's a bug in the last command, because `grep -F` find partial matches. For example, if `python3` is installed, it will also match all python3 libraries (`python3-click-package`) including ones that are no longer installed. Moreover, `grep -Fw` doesn't help because `-` is a word boundary.

  • There is a package called wajig Check it out for the command line, it is the first thing I install now. Like aptitude, except that it works like you'd expect a command dispatcher to work. So really, it's not like aptitude. Commands below are just a small subset.

    wajig help
    Common JIG commands:
    
     update         Update the list of downloadable packages
    
     new            List packages that became available since last update
     newupgrades    List packages newly available for upgrading
    
     install        Install (or upgrade) one or more packages or .deb files
     remove         Remove one or more packages (see also purge)
    
     toupgrade      List packages with newer versions available for upgrading
     upgrade        Upgrade all of the installed packages or just those listed
    
     listfiles      List the files that are supplied by the named package
     listnames      List all known packages or those containing supplied string
     whatis         For each package named obtain a one line description
     whichpkg       Find the package that supplies the given command or file
    
    Run 'wajig -v commands' for a complete list of commands.
    

    I'm not sure how `wajig` helps for listing the latest packages. I don't see a command for that after a cursory look through the commands. Do you know what the command is?

  • In addition to DoR's answer, for those who prefer a GUI, there is a File -> History menu item in Synaptic.

    And as rafalcieslak points out, this function is available in Software Center as well.

    Synaptic history only shows what you installed via Synaptic...totally useless.

  • Here is some shell to list dpkg installed files. (which should include all apt/aptitude/software center/synaptic installed packages)

    grep -A 1 "Package: " /var/lib/dpkg/status | \
    grep -B 1 -Ee "ok installed|half-installed|unpacked|half-configured|config-files" -Ee "^Essential:yes" | \
    grep "Package:" | cut -d\  -f2
    

    This does not include install time/date info. But may be useful in determining any differences in packages installed from os install to current.

  • The problem with viewing the installation history in Software Centre or Synaptic is that it's hard to copy/paste the contents into an email (e.g. when talking with tech support!). The alternative is to view the contents of the log files in /var/log/apt as root.

    Just to clarify, to simply view contents in `/var/log/apt`, you do NOT need to be root, or with any administrator's privilege.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM