如何查看apt-get安装的历史记录?

Tel*_*Why 24 history software-installation system-installation

如何查看apt-get install我手动执行的命令的历史记录?

在我看来,所有可用的方法都显示了从 Ubuntu 安装开始就已安装的所有内容。

如何查看apt-get install自系统安装过程完成以来的历史记录?

Arr*_*cal 24

我认为给出的答案在这里科斯是迄今为止我见过的最好的方式。尽管软件中心使用apt,但它已安装的任何内容也会被列出。

命令是:

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


小智 12

只需在终端中键入以下命令即可查看所有安装日志。

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


jjc*_*f89 5

为了简化@Arronical的答案,我最近学到的一个巧妙的技巧是你可以使用zcat -qfcat txt 和 txt gzipped 文件。

\n\n
zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep " install "\n
Run Code Online (Sandbox Code Playgroud)\n\n

变成

\n\n
zcat -qf /var/log/apt/history.log* | grep " install "\n
Run Code Online (Sandbox Code Playgroud)\n\n

来自 man zcat:

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