本帖最后由 darkshines 于 2012-10-5 10:43 编辑
目前在在Debian及其衍生系统上使用的包管理工具有如下几款
- dpkg //类似于RedHat中的rpm
- APT //Advanced Packaging Tool高级软件包管理工具
- 新立得 //基于图形化的包管理器,英文名synaptic http://t.cn/zlaSJBY
- aptitude //类似于RedHat中的yum
其中APT使用得比较多,它是一个套件,大家可以在命令行中输入apt然后连续按两次[Tab]查看。此篇帖子不对其做太多说明,扩展阅读 http://t.cn/zlaKAhv 。接下来上主角——Aptitude
使用APT套件实现包管理需要换命令,比如apt-get来安装卸载apt-cache来搜索查询,对于aptitude我们始终只要输入aptitude接上选项参数即可 先来看一下帮助: - aptitude 0.4.11.11
- Usage: aptitude [-S fname] [-u|-i]
- aptitude [options] <action> ...
- Actions (if none is specified, aptitude will enter interactive mode):
- install - Install/upgrade packages //安装选项
- remove - Remove packages //卸载选项
- purge - Remove packages and their configuration files //卸载同时移除配置
- hold - Place packages on hold
- unhold - Cancel a hold command for a package
- markauto - Mark packages as having been automatically installed //标记为自动安装
- unmarkauto - Mark packages as having been manually installed
- forbid-version - Forbid aptitude from upgrading to a specific package version.
- update - Download lists of new/upgradable packages //更新
- safe-upgrade - Perform a safe upgrade //安全升级,执行aptitude upgrade默认使用的方式
- full-upgrade - Perform an upgrade, possibly installing and removing packages
- forget-new - Forget what packages are "new"
- search - Search for a package by name and/or expression //搜索
- show - Display detailed information about a package //查看包信息
- clean - Erase downloaded package files //清理缓存,缓存位于/var/cache/apt/
- autoclean - Erase old downloaded package files
- changelog - View a package's changelog
- download - Download the .deb file for a package //仅下载deb包
- reinstall - Download and (possibly) reinstall a currently installed package //重新安装
- why - Show the manually installed packages that require a package, or
- why one or more packages would require the given package //why查看依赖信息
- why-not - Show the manually installed packages that lead to a conflict //查看导致冲突细节
- with the given package, or why one or more packages would
- lead to a conflict with the given package if installed
- Options:
- -h This help text
- …………
- …………
- -i Perform an install run on startup.
- This aptitude does not have Super Cow Powers.
复制代码常用的几个选项我已经做出注释,对于基本安装和卸载不多做介绍 aptitude的搜索很有用,常用在你要部署一个功能却忘记了包名,以samba服务为例 (search、install等选项后接的包名可以带通配符诸如"?" "~")
- root@anonymous:/# aptitude search samba
- …………
- …………
- i samba - SMB/CIFS file, print, and login server for Unix
- v samba-client -
- i A samba-common - common files used by both the Samba server and client i A samba-common-bin - common files used by both the Samba server and client
- …………
- …………
- p samba4-dev - tools for extending Samba
- p samba4-testsuite - test suite from Samba 4
- p system-config-samba - GUI for managing samba shares and users
复制代码search不仅匹配包名还匹配包的描述信息,上面的输出包含安装状态如"i"表示已安装 包名 简要包信息 如果我们要查看包的详细信息则用show选项
- root@anonymous:/# aptitude show samba
- Package: samba //包名
- State: installed //状态
- Automatically installed: no //自动安装 (即安装包A,包A依赖包B,B包被安装为“自动安装”)
- Version: 2:3.4.7~dfsg-1ubuntu3.6 //版本号
- Priority: optional //优先级
- Section: net //包所在类型 (samba为网络类)
- Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
- Uncompressed Size: 18.4M //解压后的大小
- Depends(依赖的包): samba-common (= 2:3.4.7~dfsg-1ubuntu3.6), samba-common-bin, libwbclient0 (= 2:3.4.7~dfsg-1ubuntu3.6),
- …………
- …………
- Recommends: logrotate
- Suggests: openbsd-inetd | inet-superserver, smbldap-tools, ldb-tools, ufw
- Conflicts: samba4 (< 4.0.0~alpha6-2) //冲突的包
- Replaces: samba-common (<= 2.0.5a-2)
- Description(功能描述): SMB/CIFS file, print, and login server for Unix
- Samba is an implementation of the SMB/CIFS protocol for Unix systems, providing support for cross-platform file and printer
- …………
- …………
- This package is not required for connecting to existing SMB/CIFS servers (see smbclient) or for mounting remote filesystems
- (see smbfs).
- Homepage(官方主页): http://www.samba.org
复制代码查看详细信息有助于更近一步判断这个包是不是我们需要部署的以及它依赖的包库。对于部署上的疑问也可以访问Homepage的链接查看文档。 另外aptitude不加参数默认使用tui形式,所谓tui就是基于文字的图形界面,这在管理员在带宽资源不充裕的远程管理环境下提供了有好的界面和顺畅的部署体验。
需要注意:不要apt-get和aptitude混搭使用,它们的记录库是分离的
错误之处大家指出交流一下。文章纯原创,转载请注明出处
|