在debian/ubuntu下,你可以使用dpkg(Debian packagesystem)来安装和卸载软件包,安装/卸载软件的最简单办法就是使用dpkg。
现在,debian/ubuntu还支持一个名为apt(for “A PackageTool”)和aptitude的工具,来帮助管理员更加简单的来管理软件。详细内容可以参考另一篇文章:如何使用apt-get和aptitude来管理软件。
1.使用dpkg -i安装deb包
语法:
dpkg -ipackage-file-name
-i is toinstall a package.
下例为使用dpkg来安装tcl
$ dpkg -itcl8.4_8.4.19-2_amd64.deb
Selecting previously deselected package tcl8.4.
(Reading database ... 94692files and directories currently installed.)
Unpacking tcl8.4 (fromtcl8.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 -rtcl8.4
(Reading database ... 94812 files and directories currentlyinstalled.)
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 okconfig-files’. 卸载命令并没有清除配置文件. 每个已安装包的状态可在/var/lib/dpkg/status查看. tcl8.4包状态如下所示,
Package: tcl8.4
Status: deinstall okconfig-files
Priority: optional
Section: interpreters
Installed-Size: 3308
以下命令表示彻底卸载软件包(包括配置文件).
$ dpkg -Ptcl8.4
(Reading database ... 94691 files and directories currentlyinstalled.)
Removing tcl8.4 ...
Purging configuration filesfor tcl8.4 ...
Processing triggers for menu...
$ dpkg -l | grep 'tcl'
$
现在软件已完全删除, 在/var/lib/dpkg/status 中查看状态如下.
Package: tcl8.4
Status: purge oknot-installed
Priority: optional
Section: interpreters