ubuntu(debian)下使用 apt-get 或 synaptic(新立得) 安装软件是件很轻松的事情. 除了简单的安装软件, apt工具集还有许多特别情况下的用法.
任何时候请记住 man 手册是良师.
1. 使用 aptitude 代替 apt-get .
aptitude 虽然没有 apt-get 的"超级牛力", 但功能却比 apt-get 更强大
首先, 像 apt-get 一样, 可以安装软件
代码:
aptitude install pack-foo
aptitude 解决依赖关系比 apt-get 更智能
. 有时用 apt-get 安装软件时会出现 "XXX 需要 XXXX, 但 XXX
已安装" 这类的错误. 这通常是因为某些软件包过新造成的. 此时使用 aptitude, aptitude 会发现问题并给出几个解决方案,
我们只需接受符合心意的方案就可以了.
aptitude 的另外一个优点是会自动记录那些包是"自动安装"(即因依赖关系而安装的), 如果依赖"自动安装"包的包都没被安装, 该"自动安装"包(此时已无用)就会自动删除.
使用这两个命令可以控制包的"自动安装"属性
代码:
aptitude markauto pack-foo #标记成"自动安装"
aptitude unmarkauto pack-foo #标记成"手动安装"
删除软件时使用 markauto 代替 remove, 就可以避免误删重要的包了.
当然, 新版的新立得和 apt-get 也有相似功能, 但貌似不与 aptitude 使用同一个数据库, 所以建议只使用 aptitude 管理软件包.
aptitude 还提供了更灵活的控制软件包版本的方式
代码:
hold - 将软件包置于保持状态
unhold - 取消对一个软件包的保持命令
forbid-version - 禁止 aptitude 升级到某一特定版本的软件包。
以前几周的 libcairo 事件作例子:
代码:
sudo aptitude install libcairo2=1.4.10-1ubuntu4 # 强制降级
sudo aptitude forbid-version libcairo2=1.4.10-1ubuntu4.1 # 封掉出错的版本
sudo aptitude markauto libcairo2 #恢复auto属性
参看 man 手册里对 install 操作的描述, 有更多控制方法.
aptitude reinstall 重新安装软件包, 相当于 apt-get --reinstall install
aptitude purge 彻底删除软件包, 相当于 apt-get --purge remove
一个小技巧
代码:
aptitude purge `dpkg -l|grep '^rc'|awk '{print $2}'`
aptitude 还集合了多个 apt 工具的功能
代码:
search - 按名称 和/或 表达式搜索软件包
show - 显示一个软件包的详细信息
download - 下载软件包的 .deb 文件
search 操作有点特别
代码:
aptitude search "foo bar" # 关键词 foo 和 bar 都要出现
aptitude search foo bar # 相当于"或"
不过 aptitude 有个小缺点, 默认会将"推荐"的包当成"依赖"的包处理. 这样设置一下就可以解决问题
在自己和root的家目录下的 .aptitude/config 文件加一句
代码:
aptitude::Recommends-Important "false";
更详细的用法参看 man aptitude.
另外:
1.aptitude 的交互模式貌似很混乱, 不如用新立得.
2.慎用 aptitude install -f .
2. 获得软件包的下载地址
很简单
使用新立得:
1.选中要安装的包
2.文件 -> 生成包下载脚本
使用 apt-get
代码:
apt-get --print-uris install pack-foo
3. 安装齐编译需要的包
首先确定你添加了 deb-src 源, 就像这种
代码:
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse
并已经 apt-get update
然后就可以
代码:
apt-get build-dep pack-foo
把编译 pack-foo 需要的包安装好
PS: 更强悍的方法是用 apt-build, 不过这样就把 ubuntu 搞的太像 gentoo 了. 有兴趣的朋友可以自己看 apt-build 的 man.
4. 找某个文件在哪个包里
如果是安装了的包, 可以用 dpkg -S, 但此法对未安装的包就无效了.
此时可使用 apt-file
代码:
$ apt-file help
apt-file version 2.0.8.2
(c) 2002 Sebastien J. Gross <sjg@debian.org>
apt-file [options] action [pattern]
Configuration options:
--sources-list -s <file> sources.list location
--cache -c <dir> Cache directory
--architecture -a <arch> Use specific architecture
--cdrom-mount -d <cdrom> Use specific cdrom mountpoint
--package-only -l Only display packages name
--fixed-string -F Do not expand pattern
--ignore-case -i Ignore case distinctions
--regexp -x pattern is a regular expression
--verbose -v run in verbose mode
--dummy -y run in dummy mode (no action)
--help -h Show this help.
--version -V Show version number
Action:
update Fetch Contents files from apt-sources.
search|find <pattern> Search files in packages
list|show <pattern> List files in packages
purge Remove cache files
此工具在寻找编译时缺的文件时很有用, 用前记得先 apt-file update
PS: auto-apt 有相同功能, 而且可以检测进程需要哪些缺少的文件, 自动提示用户选择安装相应的包.
分享到:
相关推荐
aptitude 0.7.4版本套件离线安装包,适合Ubuntu 16版本 aptitude_0.7.4-2ubuntu2_amd64.deb aptitude-common_0.7.4-2ubuntu2_all.deb libboost-iostreams1.58.0_1.58.0+dfsg-5ubuntu3_amd64.deb libcwidget3v5_...
停止猜测,并开始提高你的词汇量。...有了Aptitude单词,您就可以搜索并保存难以记住的单词列表。 不要花时间在字典中查找它们,无论您身在何处,都可以随身携带它们。 支持语言:English (United States)
适合新手看看的使用文档
语言:English (United States)停止猜测并开始改进你的词汇。我们的选择单词定义我们,为什么不扩展我们的选择? 在您身边有能力的单词,您可以搜索并保存您有困难时间记住的单词列表。 不要花时间你在字典中向上抬头...
ansible-apt:在类似Debian的系统中管理软件包和up(date | grade)的角色
C-aptitude question and answers
Validity assessment of the Woodcock-Johnson Broad Cognitive Ability and Scholastic Aptitude cluster scores for behavior-disordered adolescents Psychology in the Schools Volume 22, Oclober 1985 ...
语言:English (UK)用感谢提示替换新标签一个新的标签仪表板,用作感谢日记
Aptitude使用 Aptitude使用 Aptitude使用 Aptitude使用 Aptitude使用
aptitude install ros-noetic-navigation aptitude install ros-noetic-map-server aptitude install ros-noetic-move-base aptitude install ros-noetic-amcl 安装 符号链接where_in_q802到您的where_in_q802工作区...
Aptitude tests
aptitude简明手册 aptitude简明手册
Ubuntu 16.04默认安装php7.0环境,但是php7目前对某些旧系统的兼容性并不是很好,如果自行安装php5需要清除php7的已安装包,否则会报错。 ... ...sudo apt-get install aptitude...sudo add-apt-repository ppa:ondrej/php 安
1. 解决aptitude安装后导致apt-get失败。 2. 针对ubtuntu 18.4版本。 3. 解决apt-get安装失败。 4. 解压之后,直接运行sudo dpkg -i *.deb
由于ubuntu安装aptitude后导致apt不能使用的apt资源整合,也可以选择到服务器的后台重置服务器也可以
ledman A LED command and control thing....sudo aptitude install uwsgi uwsgi-plugin-python3 python3-bottle nginx sudo rm /etc/nginx/sites-enabled/default cp /home/pi/ledman/nginx.conf.sample /home/pi/l
Hobbyking LiPo 比较 解析 Hobbyking 上可用的所有 LiPo 电池,无论是来自全球还是美国(西部)仓库 适用于 python 2 和 3 ...使用./lipoCompare.py或python3 lipoCompare.py \ python2 lipoCompare.py 它
sudo apt-get install supervisor nginx memcached rabbitmq-server \ libxml2-dev libxslt-dev git libpq-dev virtualenvwrapper haproxy \ aptitude postgresql-9.1 postgresql-server-dev-all python-dev \ redis...
PostgreSQL - database system used for website -- aptitude install postgresql-8.4 - for Django make sure that in pg_hba.conf that MySQL - database system used with a GO database clone Apache - Web ...