debian下,你可以使用dpkg(Debian package system)来安装和卸载软件包,安装/卸载软件的最简单办法就是使用dpkg

现在,debian还支持一个名为apt(for “A Package Tool”)和aptitude的工具,来帮助管理员更加简单的来管理软件。详细内容可以参考另一篇文章:如何使用apt-get和aptitude来管理软件。

1.使用dpkg -i安装deb

语法:
dpkg -i package-file-name

-i is to install a package.

下例为使用dpkg来安装tcl

$ dpkg -i tcl8.4_8.4.19-2_amd64.deb
Selecting previously deselected package tcl8.4.
(Reading database ... 94692 files and directories currently installed.)
Unpacking tcl8.4 (from tcl8.4_8.4.19-2_amd64.deb) ...
Setting up tcl8.4 (8.4.19-2) ...
Processing triggers for menu ...
Processing triggers for man-db ...

如下所示,你可以使用dpkg -l +名称 来验证安装

$ dpkg -l | grep 'tcl'
ii  tcl8.4                               8.4.19-2                   Tcl (the Tool Command Language) v8.4 - run-t

上面命令显示tcl包是否安装正确,其中“ii”表示“installed ok installed”

2.使用kpkg -r来删除deb包

dpkg 加上 -r参数,用于卸载已安装好的软件包

$ dpkg -r tcl8.4
(Reading database ... 94812 files and directories currently installed.)
Removing tcl8.4 ...
Processing triggers for man-db ...
Processing triggers for menu ...

现在检查软件包的状态.

# dpkg -l | grep 'tcl'
rc  tcl8.4                                8.4.19-2                   Tcl (the Tool Command Language) v8.4 - run-t

rc 代表 ‘removed ok config-files’. 卸载命令并没有清除配置文件. 每个已安装包的状态可在 /var/lib/dpkg/status查看.  tcl8.4 包状态如下所示,

Package: tcl8.4
Status: deinstall ok config-files
Priority: optional
Section: interpreters
Installed-Size: 3308

以下命令表示彻底卸载软件包(包括配置文件).

$ dpkg -P tcl8.4
(Reading database ... 94691 files and directories currently installed.)
Removing tcl8.4 ...
Purging configuration files for tcl8.4 ...
Processing triggers for menu ...
$ dpkg -l | grep 'tcl'
$

现在软件已完全删除, 在 /var/lib/dpkg/status 中查看状态如下.

Package: tcl8.4
Status: purge ok not-installed
Priority: optional
Section: interpreters

本文由阿泉译自http://www.thegeekstuff.com/2010/06/install-remove-deb-package/,转载时请保留译者信息。

原创文章,转载请注明: 转载自阿泉个站

本文链接地址: debian下使用dpkg来安装/卸载deb包