运行“apt-get remove dependencies-names”后,“dpkg -l”中仍然存在依赖关系

我怀疑安装xfce4会导致Ubuntu出现一些问题,所以我使用apt-get remove xfce4 xfce4-goodeis删除了它们。

但是当我运行’dpkg -l’时,我仍然可以看到xfce4的一些库和包:

 $ dpkg -l | grep -i xfce rc libexo-1-0:amd64 0.10.2-2 amd64 Library with extensions for Xfce rc libgarcon-1-0 0.2.1-1 amd64 freedesktop.org compliant menu implementation for Xfce rc libxfce4ui-1-0 4.11.0-0ubuntu1~ppa0.13.10.1 amd64 widget library for Xfce - Gtk+2 variant rc libxfce4ui-common 4.11.0-0ubuntu1~ppa0.13.10.1 all common files for libxfce4ui rc libxfce4util6 4.10.1-1 amd64 Utility functions library for Xfce4 rc libxfcegui4-4 4.10.0-2 amd64 Basic GUI C functions for Xfce4 rc libxfconf-0-2 4.10.0-2 amd64 Client library for Xfce4 configure interface rc mousepad 0.3.0-2 amd64 simple Xfce oriented text editor rc thunar 1.6.3-1ubuntu1 amd64 File Manager for Xfce rc xfce4-appfinder 4.10.1-1 amd64 Application finder for the Xfce4 Desktop Environment rc xfce4-clipman 2:1.2.3-2ubuntu1 amd64 clipboard history utility rc xfce4-mixer 1:4.10.0-1ubuntu2 amd64 Xfce mixer application rc xfce4-notes 1.7.7-3ubuntu2 amd64 Notes application for the Xfce4 desktop rc xfce4-panel 4.10.1-1ubuntu1 amd64 panel for Xfce4 desktop environment rc xfce4-power-manager 1.2.0-2ubuntu1 amd64 power manager for Xfce desktop rc xfce4-session 4.10.1-1ubuntu1 amd64 Xfce4 Session Manager rc xfce4-settings 4.11.1-0ubuntu1~ppa0.13.10.1 amd64 graphical application for managing Xfce settings rc xfce4-terminal 0.6.2-3ubuntu1.1 amd64 Xfce terminal emulator rc xfce4-volumed 0.2.0-0ubuntu1 amd64 volume keys daemon rc xfdesktop4 4.11.2-0ubuntu1~ppa0.13.10.1 amd64 xfce desktop background, icons and root menu manager rc xfwm4 4.11.1-0ubuntu1~ppa0.13.10.1 amd64 window manager of the Xfce project 

我复制粘贴所有这些packages \ libraries以形成apt-get remove命令来删除所有这些依赖项,并且命令正常运行,但运行dpkg -l | grep -i xfce dpkg -l | grep -i xfce再次显示了这些依赖关系!

为什么还安装了这些依赖项?

请注意列表开头的rc

r :删除(标记为删除)
c :存在配置文件。

apt-get removepurge之间的区别(来自man apt-get

  remove remove is identical to install except that packages are removed instead of installed. Note the removing a package leaves its configuration files in system. purge purge is identical to remove except that packages are removed and purged (any configuration files are deleted too). 

当你选择apt-get remove ,你的dpkg -l反映出来。 如果你曾经使用过apt-get purge你可以避免这种情况。 要摆脱这些,尝试在终端,

 dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge 

它将清除所有标记为要删除的包。 在清除它们之前,您可以检查要清除的列表,

 dpkg --list | grep "^rc" | cut -d " " -f 3 

我猜你没有其他包被标记为删除,除非那些来自xfce 。 如果你不确定的话。 请改用以下内容,

 dpkg --list | grep -i xfce | cut -d " " -f 3 | xargs sudo dpkg --purge 

依赖项尚未安装。

运行dpkg -ldpkg调用dpkg-query 。 第一列(您看到rc )中的条目由两个单字母缩写组成。

第一个字母指定包管理操作指定的包的所需状态。 r表示打算将其删除。 这意味着它

  • 实际上是删除,
  • 已指定删除但尚未完全删除或删除失败。

要查看情况,请参阅第二个字母c 。 这表示从包中安装了什么。 如果没有任何类型的文件 ,第二个字母读取n (实际上,因为你运行dpkg -l / dpkg --list而没有参数然后解析输出,如果有的话,条目根本就不会出现没有文件)。

c表示所有安装的都是配置文件 。 通常,假设用户在卸载软件包时想要删除这些内容是不安全的。 如果要删除它们,可以在卸载软件包时将--purge标志传递给apt-get (或指定purge操作而不是remove操作)。

要删除这些配置文件,即使卸载了软件包本身,您仍然可以使用dpkg -P ...apt-get purge ...清除它们。 使用dpkg清除许多包可能有点复杂,但apt-get将匹配包名称的正则表达式 (如grep所做)。 假设你想要一个删除所有这些软件包的短命令,并假设你真的想要删除名字中包含xfce所有软件包,这样就可以了:

 sudo apt-get purge xfce.\* 

请注意, * 不是通配符, .\*匹配任何字符的零个或多个。 这个. 对于实现这一点至关重要(见下文)。 这个正则表达式只相当于xfce ,但它被apt-get 识别为正则表达式,因为它包含特殊字符*

(同样,如果您使用xfce\*xfce*它会删除名称中包含xfc所有包。人们试图通过删除wine*来摆脱Wine,这导致每个名称中包含win包都被删除,打破他们的系统!)

或者如果您更喜欢使用dpkg进行清除,那么这样做的一种容易理解的方式(我认为这样可以减少错误)就是告诉dpkg-list如何格式化自己的输出:

 sudo dpkg -P `dpkg-query -f='${Package}\n' -W | grep xfce` 

或者你可以简单地运行dpkg-query -f='${Package} ' -W | grep xfce dpkg-query -f='${Package} ' -W | grep xfce ,让你检查输出以确保它是你想要的,然后将这个以空格分隔的包列表复制并粘贴到sudo apt-get purgesudo dpkg -P命令中。