卸载删除已安装的 `.deb` 包

下面以删除xminddeb包为例, 简述移除过程:

查询你要删除的包信息:

$ dpkg -l | grep xmind
ii xmind 3.6.51 amd64 Professional & Powerful Mind Mapping Software

ii 表示installed ok installed.

-r 移除

$ dpkg -r xmind
dpkg: error: requested operation requires superuser privilege
niko@ubuntu14:/usr/lib/xmind$ sudo dpkg -r xmind
(Reading database ... 178948 files and directories currently installed.)
Removing xmind (3.6.51) ...
Processing triggers for shared-mime-info (1.2-0ubuntu3) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for fontconfig (2.11.0-0ubuntu4) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.54ubuntu1) ...

再次查询

$ dpkg -l | grep xmind
rc xmind 3.6.51 amd64 Professional & Powerful Mind Mapping Software

为什么删除了仍然可以查询到呢?

我们留意到ii已经变成了rc, 表示removed ok config-files,
-r没有移除配置文件, 已安装的包状态是存在/var/lib/dpkg/status中.

比如, 可以查看一下xmind的信息:

Package: xmind
Status: deinstall ok config-files
Priority: optional
Section: non-free/editors
Installed-Size: 148888
Maintainer: XMind Ltd. <dev@xmind.net>
Architecture: amd64
Version: 3.6.51
Config-Version: 3.6.51
Depends: default-jre (>= 2:1.7-0) | java7-runtime | java8-runtime, libgtk2.0-0 (>= 2.8.0), libwebkitgtk-1.0-0, lame, libc6 (>= 2.7), libglib2.0-0 (>= 2.12.0)
Conffiles:
/etc/XMind.ini 3553ecb1eb8875b4be37733ce8f29839
Description: Professional & Powerful Mind Mapping Software
XMind, is an open source brainstorming and mind mapping software tool
developed by XMind Ltd. It helps people to capture ideas, organize to
various charts, and share them for collaboration. Supporting mind maps,
fishbone diagrams, tree diagrams, org-charts, logic charts, and even
matrix. Often used for knowledge management, meeting minutes, task
management, and GTD. XMind is compatible with Freemind/Mindmanager.
XMind is dual licensed under 2 open source licenses: the Eclipse Public
License v1.0 (EPL) and the GNU Lesser General Public License v3 (LGPL).
XMind Plus/Pro is released under the terms of the XMIND PROPRIETARY LICENSE
AGREEMENT, which is available at http://www.xmind.net/license/xpla/ .

状态是Status: deinstall ok config-files.

-P purge

如果要完全移除xmind程序和配置, 可使用-P:

$ sudo dpkg -P xmind
[sudo] password for niko:
(Reading database ... 175311 files and directories currently installed.)
Removing xmind (3.6.51) ...
Purging configuration files for xmind (3.6.51) ...

参考