Debian&Ubuntu包管理指南之Aptitude
本帖最后由 darkshines 于 2012-10-5 10:43 编辑目前在在Debian及其衍生系统上使用的包管理工具有如下几款
[*]dpkg //类似于RedHat中的rpm
[*]APT //Advanced Packaging Tool高级软件包管理工具
[*]新立得 //基于图形化的包管理器,英文名synaptic http://t.cn/zlaSJBY
[*]aptitude //类似于RedHat中的yum
其中APT使用得比较多,它是一个套件,大家可以在命令行中输入apt然后连续按两次查看。此篇帖子不对其做太多说明,扩展阅读 http://t.cn/zlaKAhv 。接下来上主角——Aptitude
使用APT套件实现包管理需要换命令,比如apt-get来安装卸载apt-cache来搜索查询,对于aptitude我们始终只要输入aptitude接上选项参数即可先来看一下帮助:aptitude 0.4.11.11
Usage: aptitude [-S fname] [-u|-i]
aptitude <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混搭使用,它们的记录库是分离的
错误之处大家指出交流一下。文章纯原创,转载请注明出处
apt-get以及aptitude中的彩蛋
本帖最后由 darkshines 于 2012-10-5 10:28 编辑查看apt-get信息最后一行
This APT has Super Cow Powers.
而查看aptitude帮助最后一行
This aptitude does not have Super Cow Powers.
想必这两个程序有隐藏彩蛋apt-get的彩蛋是这样的
root@anonymous:~# apt-get moo
(__)
(oo)
/------\/
/ | ||
*/\---/\
~~ ~~
...."Have you mooed today?"...
而aptitude则更费一番功夫才能看到隐藏内容
root@anonymous:~# aptitudemoo
There are no Easter Eggs in this program. //本程序木有彩蛋
root@anonymous:~# aptitude -v moo
There really are no Easter Eggs in this program. //真的木有啦
root@anonymous:~# aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program? //都说过没有啦,你难道没听到?
root@anonymous:~# aptitude -vvv moo
Stop it! //站住!靠近我就叫警察蜀黍啦!
root@anonymous:~# aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away? //好啦好啦,给你彩蛋,你快走开
root@anonymous:~# aptitude -vvvvv moo //话说这个图形我没看出是神马
All right, you win.
/----\
-------/ \
/ \
/ |
-----------------/ --------\
----------------------------------------------
对于apt-get,拿rpm来类比其实是不恰当的。rpm和dpkg都是底层的低级包管理器,负责安装,升级,记录软件包,但是不具备自动解决依赖的功能。
apt-get,aptitude,yum都属于高级包管理器,虽然在后端仍然调用dpkg和rpm以及其他触发器,但是它们都具有自动解决依赖的功能。
和apt-get相比,aptitude只是更智能,解决依赖更彻底,而且能针对性给用户提供解决依赖的方案。这些功能是apt-get所不具备的。
因此,个人认为,aptitude算是增强版的apt-get。 darkduke 发表于 2012-10-3 11:12 static/image/common/back.gif
对于apt-get,拿rpm来类比其实是不恰当的。rpm和dpkg都是底层的低级包管理器,负责安装,升级,记录软件包, ...
你说的更精确。
apt-get能智能解决依赖问题,不过它不能提供完整的包管理功能。
我觉得不值得推广它的使用,很多文档的安装说明都用apt-get不知道是什么原因。 darkshines 发表于 2012-10-3 11:21 static/image/common/back.gif
你说的更精确。
apt-get能智能解决依赖问题,不过它不能提供完整的包管理功能。
我觉得不值得推广它的使 ...
记得在哪看到,很多人喜欢yum的很重要一点就是因为它输入起来更短……
或许可以解释你的疑惑? jeff2229 发表于 2012-10-3 11:56 static/image/common/back.gif
记得在哪看到,很多人喜欢yum的很重要一点就是因为它输入起来更短……
或许可以解释你的疑惑?
输入的时候都是tab补全的,apt-get的补全输入长度为apt-g,而aptitude的补全输入长度为apti比apt-get还少一个字符。 darkshines 发表于 2012-10-3 12:07 static/image/common/back.gif
输入的时候都是tab补全的,apt-get的补全输入长度为apt-g,而aptitude的补全输入长度为apti比apt-get还少 ...
哟西。
刚试了一下,openSUSE下只要apt三个字母,就能自动补全aptitude了。
话说我也只用过apt-get。为什么少见aptitude可能是因为……习惯? 因为大家都推广apt-get,所以就用的人多了 原来是这样啊 代码框里是无法显示红字的哦。
如果您可以补充一下资料,我会去申请精华
感谢您的支持。 进来学习一下,虽然还是不太懂 原来用ubuntu这么久了,我还没有用过这个命令,不过见倒是见得挺多的。
一直都没有man一下是干什么用的。
页:
[1]