Total Pageviews

Monday 8 October 2012

debian下使用dpkg来安装/卸载deb包的命令

1.使用dpkg -i安装deb包

语法:
dpkg -i package-file-name.deb

-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/