Is it possible to get a list of packages that were most recently installed through apt-get?
9 Answers
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
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 "
- 1,138
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.
- 21,004
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}'
- 5,719
- 1
- 54
- 59
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 -12lists lines common to two sorted files.<(command)expands to the name of a file containing the output ofcommand.apt-mark showmanuallists manually installed packages; ie. those that should never be auto-removed.grep " install " /var/log/dpkg.logis 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.
- 362
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.
- 74
Very late to the game, but here's the command line that I found most informative:
$ grep -e upgrade -e install /var/log/dpkg.log
2024-01-22 10:26:37 upgrade libssh-4:amd64 0.10.5-3ubuntu1.1 0.10.5-3ubuntu1.2
2024-01-22 10:26:37 status half-installed libssh-4:amd64 0.10.5-3ubuntu1.1
2024-01-22 10:26:37 upgrade libssh-gcrypt-4:amd64 0.10.5-3ubuntu1.1 0.10.5-3ubuntu1.2
2024-01-22 10:26:37 status half-installed libssh-gcrypt-4:amd64 0.10.5-3ubuntu1.1
2024-01-22 10:26:38 status installed libssh-gcrypt-4:amd64 0.10.5-3ubuntu1.2
2024-01-22 10:26:38 status installed libssh-4:amd64 0.10.5-3ubuntu1.2
2024-01-22 10:26:38 status installed libc-bin:amd64 2.38-1ubuntu6
2024-01-22 10:26:39 upgrade libgnutls30:amd64 3.8.1-4ubuntu1.1 3.8.1-4ubuntu1.2
2024-01-22 10:26:39 status half-installed libgnutls30:amd64 3.8.1-4ubuntu1.1
2024-01-22 10:26:40 status installed libgnutls30:amd64 3.8.1-4ubuntu1.2
2024-01-22 10:26:40 status installed libc-bin:amd64 2.38-1ubuntu6
2024-01-24 14:45:20 upgrade google-chrome-stable:amd64 120.0.6099.224-1 121.0.6167.85-1
2024-01-24 14:45:20 status half-installed google-chrome-stable:amd64 120.0.6099.224-1
2024-01-24 14:45:24 status installed google-chrome-stable:amd64 121.0.6167.85-1
2024-01-24 14:45:24 status installed gnome-menus:amd64 3.36.0-1.1ubuntu1
2024-01-24 14:45:25 status installed man-db:amd64 2.11.2-3
2024-01-24 14:45:25 status installed mailcap:all 3.70+nmu1ubuntu1
2024-01-24 14:45:25 status installed desktop-file-utils:amd64 0.26-1ubuntu5
This greps through the whole log (a month's worth, for me), but the last lines are the most recent and just what I was looking for.
- 131
In addition to DoR's answer, for those who prefer a GUI, there is a File -> History menu item in Synaptic.
- 19,802
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.
- 1,474