我使用的是 xubuntu 22.04。当我安装带有依赖项的 libreoffice 时,它占用了 682 MB 的空间。当我立即使用 --purge 和 --autoremove 标志将其删除时,它只释放了 387MB 的空间,留下了许多软件包。为什么?我该如何解决这个问题?
然后我手动卸载了其余的软件包,释放了剩下的 296 MB。
~$ sudo apt install libreoffice
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java default-jre default-jre-headless firebird3.0-common firebird3.0-common-doc firebird3.0-server-core firebird3.0-utils fonts-crosextra-caladea fonts-crosextra-carlito fonts-dejavu fonts-dejavu-extra
fonts-linuxlibertine fonts-noto-extra fonts-sil-gentium fonts-sil-gentium-basic gstreamer1.0-gl gstreamer1.0-gtk3 java-common libabw-0.1-1 libatk-wrapper-java libatk-wrapper-java-jni libbsh-java libcdr-0.1-1 libe-book-0.1-1
libel-api-java libepubgen-0.1-1 libfbclient2 libfreehand-0.1-1 libgraphene-1.0-0 libgstreamer-gl1.0-0 libhsqldb1.8.0-java libib-util libjsp-api-java liblibreoffice-java libmspub-0.1-1 libmysqlclient21 libpagemaker-0.0-0 libpq5
libreoffice-base libreoffice-base-drivers libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-java-common libreoffice-math libreoffice-nlpsolver libreoffice-report-builder libreoffice-report-builder-bin
libreoffice-script-provider-bsh libreoffice-script-provider-js libreoffice-script-provider-python libreoffice-sdbc-firebird libreoffice-sdbc-hsqldb libreoffice-sdbc-mysql libreoffice-sdbc-postgresql libreoffice-style-elementary
libreoffice-style-yaru libreoffice-wiki-publisher libreoffice-writer libservlet-api-java libservlet3.1-java libtommath1 libunoloader-java libvisio-0.1-1 libwebsocket-api-java libwpd-0.10-10 libwpg-0.3-3 openjdk-11-jre
openjdk-11-jre-headless ure-java
Suggested packages:
firebird3.0-server firebird3.0-doc java-virtual-machine libhsqldb1.8.0-java-gcj gpa imagemagick | graphicsmagick-imagemagick-compat libreoffice-grammarcheck libreoffice-help libreoffice-l10n libreoffice-librelogo myspell-dictionary
openclipart-libreoffice pstoedit unixodbc gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-libav libsane1 libofficebean-java libjtds-java libsqliteodbc | tdsodbc | odbc-mdbtools
libreoffice-evolution seahorse libreofficekit-data bluez default-mysql-server | virtual-mysql-server postgresql mediawiki fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei
The following NEW packages will be installed:
ca-certificates-java default-jre default-jre-headless firebird3.0-common firebird3.0-common-doc firebird3.0-server-core firebird3.0-utils fonts-crosextra-caladea fonts-crosextra-carlito fonts-dejavu fonts-dejavu-extra
fonts-linuxlibertine fonts-noto-extra fonts-sil-gentium fonts-sil-gentium-basic gstreamer1.0-gl gstreamer1.0-gtk3 java-common libabw-0.1-1 libatk-wrapper-java libatk-wrapper-java-jni libbsh-java libcdr-0.1-1 libe-book-0.1-1
libel-api-java libepubgen-0.1-1 libfbclient2 libfreehand-0.1-1 libgraphene-1.0-0 libgstreamer-gl1.0-0 libhsqldb1.8.0-java libib-util libjsp-api-java liblibreoffice-java libmspub-0.1-1 libmysqlclient21 libpagemaker-0.0-0 libpq5
libreoffice libreoffice-base libreoffice-base-drivers libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-java-common libreoffice-math libreoffice-nlpsolver libreoffice-report-builder
libreoffice-report-builder-bin libreoffice-script-provider-bsh libreoffice-script-provider-js libreoffice-script-provider-python libreoffice-sdbc-firebird libreoffice-sdbc-hsqldb libreoffice-sdbc-mysql libreoffice-sdbc-postgresql
libreoffice-style-elementary libreoffice-style-yaru libreoffice-wiki-publisher libreoffice-writer libservlet-api-java libservlet3.1-java libtommath1 libunoloader-java libvisio-0.1-1 libwebsocket-api-java libwpd-0.10-10 libwpg-0.3-3
openjdk-11-jre openjdk-11-jre-headless ure-java
0 upgraded, 72 newly installed, 0 to remove and 0 not upgraded.
Need to get 165 MB of archives.
After this operation, 682 MB of additional disk space will be used.
Do you want to continue? [Y/n]
~$ sudo apt remove --purge --autoremove libreoffice
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
fonts-dejavu* fonts-linuxlibertine* fonts-noto-extra* fonts-sil-gentium* fonts-sil-gentium-basic* gstreamer1.0-gl* gstreamer1.0-gtk3* libbsh-java* libcdr-0.1-1* libfreehand-0.1-1* libgraphene-1.0-0* libgstreamer-gl1.0-0*
libmspub-0.1-1* libpagemaker-0.0-0* libreoffice* libreoffice-draw* libreoffice-gnome* libreoffice-gtk3* libreoffice-impress* libreoffice-nlpsolver* libreoffice-script-provider-bsh* libreoffice-script-provider-js*
libreoffice-script-provider-python* libreoffice-wiki-publisher* libvisio-0.1-1*
0 upgraded, 0 newly installed, 25 to remove and 0 not upgraded.
After this operation, 387 MB disk space will be freed.
Do you want to continue? [Y/n]
~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~$ sudo apt remove --purge --autoremove ca-certificates-java default-jre default-jre-headless firebird3.0-common firebird3.0-common-doc firebird3.0-server-core firebird3.0-utils fonts-crosextra-caladea fonts-crosextra-carlito fonts-dejavu fonts-dejavu-extra fonts-linuxlibertine fonts-noto-extra fonts-sil-gentium fonts-sil-gentium-basic gstreamer1.0-gl gstreamer1.0-gtk3 java-common libabw-0.1-1 libatk-wrapper-java libatk-wrapper-java-jni libbsh-java libcdr-0.1-1 libe-book-0.1-1 libel-api-java libepubgen-0.1-1 libfbclient2 libfreehand-0.1-1 libgraphene-1.0-0 libgstreamer-gl1.0-0 libhsqldb1.8.0-java libib-util libjsp-api-java liblibreoffice-java libmspub-0.1-1 libmysqlclient21 libpagemaker-0.0-0 libpq5 libreoffice libreoffice-base libreoffice-base-drivers libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-java-common libreoffice-math libreoffice-nlpsolver libreoffice-report-builder libreoffice-report-builder-bin libreoffice-script-provider-bsh libreoffice-script-provider-js libreoffice-script-provider-python libreoffice-sdbc-firebird libreoffice-sdbc-hsqldb libreoffice-sdbc-mysql libreoffice-sdbc-postgresql libreoffice-style-elementary libreoffice-style-yaru libreoffice-wiki-publisher libreoffice-writer libservlet-api-java libservlet3.1-java libtommath1 libunoloader-java libvisio-0.1-1 libwebsocket-api-java libwpd-0.10-10 libwpg-0.3-3 openjdk-11-jre openjdk-11-jre-headless ure-java
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'gstreamer1.0-gl' is not installed, so not removed
Package 'libcdr-0.1-1' is not installed, so not removed
Package 'libfreehand-0.1-1' is not installed, so not removed
Package 'libgraphene-1.0-0' is not installed, so not removed
Package 'libgstreamer-gl1.0-0' is not installed, so not removed
Package 'libmspub-0.1-1' is not installed, so not removed
Package 'libpagemaker-0.0-0' is not installed, so not removed
Package 'libvisio-0.1-1' is not installed, so not removed
Package 'fonts-dejavu' is not installed, so not removed
Package 'fonts-linuxlibertine' is not installed, so not removed
Package 'fonts-noto-extra' is not installed, so not removed
Package 'fonts-sil-gentium' is not installed, so not removed
Package 'fonts-sil-gentium-basic' is not installed, so not removed
Package 'libbsh-java' is not installed, so not removed
Package 'gstreamer1.0-gtk3' is not installed, so not removed
Package 'libreoffice-draw' is not installed, so not removed
Package 'libreoffice-gnome' is not installed, so not removed
Package 'libreoffice-gtk3' is not installed, so not removed
Package 'libreoffice-impress' is not installed, so not removed
Package 'libreoffice-nlpsolver' is not installed, so not removed
Package 'libreoffice' is not installed, so not removed
Package 'libreoffice-script-provider-bsh' is not installed, so not removed
Package 'libreoffice-script-provider-js' is not installed, so not removed
Package 'libreoffice-script-provider-python' is not installed, so not removed
Package 'libreoffice-wiki-publisher' is not installed, so not removed
The following packages will be REMOVED:
ca-certificates-java* default-jre* default-jre-headless* firebird3.0-common* firebird3.0-common-doc* firebird3.0-server-core* firebird3.0-utils* fonts-crosextra-caladea* fonts-crosextra-carlito* fonts-dejavu-extra* java-common*
libabw-0.1-1* libatk-wrapper-java* libatk-wrapper-java-jni* libe-book-0.1-1* libel-api-java* libepubgen-0.1-1* libfbclient2* libhsqldb1.8.0-java* libib-util* libjsp-api-java* liblibreoffice-java* libmysqlclient21* libpq5*
libreoffice-base* libreoffice-base-drivers* libreoffice-java-common* libreoffice-math* libreoffice-report-builder* libreoffice-report-builder-bin* libreoffice-sdbc-firebird* libreoffice-sdbc-hsqldb* libreoffice-sdbc-mysql*
libreoffice-sdbc-postgresql* libreoffice-style-elementary* libreoffice-style-yaru* libreoffice-writer* libservlet-api-java* libservlet3.1-java* libtommath1* libunoloader-java* libwebsocket-api-java* libwpd-0.10-10* libwpg-0.3-3*
openjdk-11-jre* openjdk-11-jre-headless* ure-java*
0 upgraded, 0 newly installed, 47 to remove and 0 not upgraded.
After this operation, 296 MB disk space will be freed.
Do you want to continue? [Y/n]
答案1
这一切都取决于如何标记作为依赖项引入的包。包可以标记为自动地已安装,或手动已安装。因此,您明确安装的软件包被标记为手动安装。您尝试安装的软件包(如果已安装并标记为自动安装)将被标记为手动安装。重要的是要意识到,在软件包安装过程中引入的依赖项不一定被标记为自动安装。后者解释了您的观察结果。
将自动安装的依赖项标记为手动安装是为了防止自动删除依赖项时出现不必要的问题。一个典型的例子是元包,例如ubuntu-desktop
。元包仅用作组成默认 Ubuntu 桌面的组件列表。删除默认桌面的一个组件将删除元包。不希望后续的自动删除操作导致整个桌面关闭。因此,元包中列出的“顶级”包被标记为手动安装,因此即使删除了元包,它们仍会保留在系统中。
在安装 libreoffice 时,您会看到类似的事情发生。作为软件包依赖项拉取的选定软件包libreoffice
及其依赖项也被标记为手动安装。哪些是由软件包开发人员在软件包准备期间决定的。
因此,不仅是系统管理员的操作,而且开发人员定义软件包的方式也决定了软件包的自动安装和删除。
答案2
tldr;我无法确认这一点。
我创建了一个全新的/干净的 ubuntu 22.04。
计算已安装的软件包:
sudo dpkg -l | wc -l
600
好的,600 个软件包,接下来让我们安装 libreoffice
sudo apt install libreoffice
...
317 newly installed
将安装 317 个新软件包。安装完成后,让我们再次统计一下已安装的软件包:
sudo dpkg -l | wc -l
917
600+317=917
看起来还不错。
现在让我们删除并清除 libreoffice
sudo apt -y autoremove --purge libreoffice
...
0 upgraded, 0 newly installed, 317 to remove and 0 not upgraded.
After this operation, 1448 MB disk space will be freed.
Do you want to continue? [Y/n]
...
317 删除
最后再次计算已安装的软件包:
sudo dpkg -l | wc -l
600