如何使用“aptitude”查看在给定日期安装的软件包?

Mik*_*age 57 package-management aptitude apt

有谁知道在使用aptitude(或apt-get)时是否有一种简单的方法可以找到已安装的软件包列表,按日期排序?

我安装了一堆软件包来尝试新的东西,但没有成功。我想删除所有这些包,以取回一些磁盘空间。

我试过只查看下载的 .deb 文件列表,但这似乎是一种相当落后的方法(尽管它确实有效)。

小智 44

不幸的是,dpkg(包处理程序 aptitude 在其上工作)并没有专门保存包的安装日期,尽管有添加它的想法。但是,可以通过查看写入目录的文件的日期戳来找到安装日期/var/lib/dpkg/info

  • 如果您使用这种方法,请确保只检查 `*.list` 文件上的时间戳,因为其他文件都标有包日期。 (4认同)

jer*_*iah 21

我已将 aptitude 配置为写入日志 ( /var/log/aptitude)。它产生这样的输出;

Aptitude 0.4.11.11: log report
Mon, Feb  9 2009 13:21:28 +0100

IMPORTANT: this log only lists intended actions; actions which fail due to
dpkg problems may not be completed.

Will install 6 packages, and remove 0 packages.
4096B of disk space will be used
===============================================================================
[UPGRADE] apt 0.7.20.1 -> 0.7.20.2
[UPGRADE] apt-utils 0.7.20.1 -> 0.7.20.2
[UPGRADE] base-passwd 3.5.19 -> 3.5.20
[UPGRADE] libgnutls26 2.4.2-5 -> 2.4.2-6
[UPGRADE] libpq5 8.3.5-1 -> 8.3.6-1
[UPGRADE] ucf 3.0015 -> 3.0016
===============================================================================

Log complete.
Run Code Online (Sandbox Code Playgroud)

这显示了 aptitude 安装的确切日期和软件包。要配置它,请遵循 aptitude 参考;

Option:Aptitude::Log

Default:/var/log/aptitude

Description: If this is set to a nonempty string, aptitude will log the package
installations, removals, and upgrades that it performs. If the value of
Aptitude::Log begins with a pipe character (ie, ``|''), the remainder of its
value is used as the name of a command into which the log will be piped: for
instance, |mail -s 'Aptitude install run' root will cause the log to be emailed
to root. To log to multiple files or commands, you may set this option to a list
of log targets.
Run Code Online (Sandbox Code Playgroud)

您将在 aptitude 手册页中找到 aptitude 参考的链接。

  • 请发布链接以及如何实现它。仅仅参考一些手册文本并不是很有帮助。 (2认同)

jma*_*eli 17

有一种简单的方法可以查看所有软件包的安装日期。只需执行:

grep " install" /var/log/dpkg.log*
Run Code Online (Sandbox Code Playgroud)

因此,您将获得所有已安装软件包的列表,其中包含确切的日期和时间。

感谢您的评论引导我找到该解决方案。

  • 如果在 `cat` 命令中使用完整路径,则不需要 `cd` 命令... (2认同)
  • 或者只是“grep install /var/log/dpkg.log*”? (2认同)

gue*_*rda 13

我在网上找到了这个。它从 dpkg 日志文件中创建 dpkg 的历史记录。

它看起来非常简单。

function apt-history(){
      case "$1" in
        install)
              cat /var/log/dpkg.log | grep 'install '
              ;;
        upgrade|remove)
              cat /var/log/dpkg.log | grep $1
              ;;
        rollback)
              cat /var/log/dpkg.log | grep upgrade | \
                  grep "$2" -A10000000 | \
                  grep "$3" -B10000000 | \
                  awk '{print $4"="$5}'
              ;;
        *)
              cat /var/log/dpkg.log
              ;;
      esac
}
Run Code Online (Sandbox Code Playgroud)

来源

编辑

我在 Ubuntu 8.10 Server 上试过这个脚本,效果很好。你能提供一些信息,你是如何解决你的问题的?


a20*_*a20 6

例如对于最后一个命令,我得到:

2014-10-08 18:56:12 install xorg-server-source:all <none> 2:1.16.1-1
2014-10-08 18:49:34 install libelementary-data:all <none> 0.7.0.55225-1
2014-10-08 18:46:57 install e17:i386 <none> 0.17.6-1
2014-10-08 18:46:56 install libedje-bin:i386 <none> 1.8.6-2.1+b1
Run Code Online (Sandbox Code Playgroud)