如何列出APT命令安装的所有文件

如何列出APT命令安装的所有文件

我试过如何列出 APT 软件包已安装的所有文件?。但问题是,例如:

当我运行它时,sudo apt install libvirt-daemon-system它不仅安装一个包(在本例中libvirt-daemon-system)。它还安装下面提到的软件包将安装以下新软件包:

$ sudo apt install libvirt-daemon-system
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  cpu-checker ibverbs-providers ipxe-qemu ipxe-qemu-256k-compat-efi-roms libcacard0 libfdt1 libibverbs1 libiscsi7 libpmem1 librados2 librbd1
  librdmacm1 libslirp0 libspice-server1 libusbredirparser1 libvirglrenderer1 libvirt-clients libvirt-daemon libvirt-daemon-driver-qemu
  libvirt-daemon-driver-storage-rbd libvirt-daemon-system-systemd libvirt0 msr-tools ovmf qemu-block-extra qemu-kvm qemu-system-common
  qemu-system-data qemu-system-gui qemu-system-x86 qemu-utils seabios
Suggested packages:
  libvirt-daemon-driver-lxc libvirt-daemon-driver-vbox libvirt-daemon-driver-xen libvirt-daemon-driver-storage-gluster
  libvirt-daemon-driver-storage-zfs numad auditd nfs-common open-iscsi radvd systemtap zfsutils samba vde2 debootstrap
The following NEW packages will be installed:
  cpu-checker ibverbs-providers ipxe-qemu ipxe-qemu-256k-compat-efi-roms libcacard0 libfdt1 libibverbs1 libiscsi7 libpmem1 librados2 librbd1
  librdmacm1 libslirp0 libspice-server1 libusbredirparser1 libvirglrenderer1 libvirt-clients libvirt-daemon libvirt-daemon-driver-qemu
  libvirt-daemon-driver-storage-rbd libvirt-daemon-system libvirt-daemon-system-systemd libvirt0 msr-tools ovmf qemu-block-extra qemu-kvm
  qemu-system-common qemu-system-data qemu-system-gui qemu-system-x86 qemu-utils seabios
0 upgraded, 33 newly installed, 0 to remove and 1 not upgraded.
Need to get 22.4 MB of archives.
After this operation, 93.9 MB of additional disk space will be used.
Do you want to continue? [Y/n]

所以,我没有通过跑步来了解全貌dpkg -L libvirt-daemon-system

获取命令后创建的所有文件列表的一种选择apt install是运行

dpkg -L libvirt-daemon-system
dpkg -L cpu-checker
dpkg -L ibverbs-providers
dpkg -L ipxe-qemu
....

但我认为这将是一个漫长的过程。

另一种选择是在安装软件包后运行以下命令:

sudo find / -xdev -mtime -5 -type f ! -path '/home/blueray/*' ! -path '/timeshift/*'

是否有更好的解决方案来获取命令后创建的所有文件的列表apt install

答案1

之后,您可以将已安装软件包的列表提供给dpkg -L

dpkg -L libvirt-daemon-system cpu-checker ibverbs-providers ipxe-qemu \
        ipxe-qemu-256k-compat-efi-roms libcacard0 libfdt1 libibverbs1 \
        libiscsi7 libpmem1 librados2 librbd1 librdmacm1 libslirp0  \
        libspice-server1 libusbredirparser1 libvirglrenderer1 \
        libvirt-clients libvirt-daemon libvirt-daemon-driver-qemu \
        libvirt-daemon-driver-storage-rbd libvirt-daemon-system \
        libvirt-daemon-system-systemd libvirt0 msr-tools ovmf \
        qemu-block-extra qemu-kvm qemu-system-common qemu-system-data \
        qemu-system-gui qemu-system-x86 qemu-utils seabios

在大多数情况下这不会很长(尽管结果可以,并且在本例中也是如此)。

经过一些准备,您可以列出软件包安装的所有文件(不包括其维护者脚本所做的更改)。在运行之前apt,存储打包系统知道的所有文件的列表:

sort -u /var/lib/dpkg/info/*.list > files-before

运行后apt,将其再次存储在不同的文件中:

sort -u /var/lib/dpkg/info/*.list > files-after

然后您可以比较这两个文件以查看发生了什么变化,例如

comm files-{before,after}

或者

meld files-{before,after}

这也适用于软件包删除以及软件包升级期间的文件删除;您的find方法将无法确定删除了什么。

在您只对新的(或升级的)软件包安装的文件感兴趣的情况下,您可以查看最近修改的文件列表X分钟,例如10:

find /var/lib/dpkg/info -name \*.list -mmin -10 -exec sort -u {} +

或者,如果您使用的是 Zsh:

sort -u /var/lib/dpkg/info/*.list(mm-10)

相关内容