zoukankan      html  css  js  c++  java
  • [转]Ubuntu上的包管理:dpkg,apt和aptitude

    一直以来对于ubuntu的包管理的概念就是apt-get,偶尔手动装个包就是dpkg -i,现在觉得是要系统地了解一下这几个包管理的命令。

    原文转自: http://zhouliang.pro/2011/10/23/ubuntu-apt-aptitude-dpkg/

    Ubuntu上的包管理:dpkg,apt和aptitude

    简述

    最开始的时候,Linux上的软件以源代码的方式发布,用户下载源代码包(通常打包为.tar.gz),然后自行编译。

    dpkg是Debian软件包管理器的基础,它被伊恩·默多克创建于1993年。dpkg与RPM十分相似,同样被用于安装、卸载和供给和.deb软件包相关的信息。

    dpkg本身是一个底层的工具,本身并不能从远程包仓库下载包以及处理包的依赖的关系,基于dpkg的上层工具,如APT,则用于从远程获取软件包以及处理复杂的软件包关系

    APT全称Advanced Packaging Tool,可以自动下载,配置,安装二进制或者源代码格式的软件包,因此简化了Unix系统上管理软件的过程。现在Debian和其衍生发行版(如Ubuntu)中都包含了APT。

    APT最早是基于dpkg的开发的,只用来处理deb格式的软件包。现在经过APT-RPM组织修改,APT已经可以安装在支持RPM的系统管理RPM包。

    而aptitude是一个APT的文本界面客户端,现在也逐渐加入了GUI的界面,详见http://linuxtoy.org/archives/gtk-gui-for-aptitude.html

    Synaptic是Ubuntu中自带的APT的GUI客户端,也就是传说中的新立得。

    dpkg命令

    (来自:http://linuxtoy.org/archives/dpkg_reference.html

    命令作用
    dpkg -i package.deb 安装包
    dpkg -r package 删除包
    dpkg -P package 删除包(包括配置文件)
    dpkg -L package 列出与该包关联的文件
    dpkg -l package 显示该包的版本
    dpkg --unpack package.deb 解开 deb 包的内容
    dpkg -S keyword 搜索所属的包内容
    dpkg -l 列出当前已安装的包
    dpkg -c package.deb 列出 deb 包的内容
    dpkg --configure package 配置包

    注意:更多选项可通过 dpkg -h 查询,有些指令需要超级用户权限才能执行

    APT命令

    (来自:http://linuxtoy.org/archives/apt_reference.html)

    命令作用
    apt-cache search package 搜索包
    apt-cache show package 获取包的相关信息,如说明、大小、版本等
    sudo apt-get install package 安装包
    sudo apt-get install package --reinstall 重新安装包
    sudo apt-get -f install 强制安装
    sudo apt-get remove package 删除包
    sudo apt-get remove package --purge 删除包,包括删除配置文件等
    sudo apt-get autoremove 自动删除不需要的包
    sudo apt-get update 更新源
    sudo apt-get upgrade 更新已安装的包
    sudo apt-get dist-upgrade 升级系统
    sudo apt-get dselect-upgrade 使用 dselect 升级
    apt-cache depends package 了解使用依赖
    apt-cache rdepends package 了解某个具体的依赖
    sudo apt-get build-dep package 安装相关的编译环境
    apt-get source package 下载该包的源代码
    sudo apt-get clean && sudo apt-get autoclean 清理下载文件的存档
    sudo apt-get check 检查是否有损坏的依赖

    备注:package 为软件包名称。

    aptitude命令

    (来自http://linuxtoy.org/archives/aptitude_quick_reference.html) aptitude是基于APT的又一个包管理的前端,aptitude似乎在处理依赖问题上更佳一些。据说aptitude 另外用一份数据量很小的扩展标记来实现所谓更佳的管理,我没有发现有什么比apt命令更加牛逼的功能,不过看起来命令比apt要简洁。

    命令作用
    aptitude update 更新可用的包列表
    aptitude upgrade 升级可用的包
    aptitude dist-upgrade 将系统升级到新的发行版
    aptitude install pkgname 安装包
    aptitude remove pkgname 删除包
    aptitude purge pkgname 删除包及其配置文件
    aptitude search string 搜索包
    aptitude show pkgname 显示包的详细信息
    aptitude clean 删除下载的包文件
    aptitude autoclean 仅删除过期的包文件

    当然aptitude也是text-based,也就是命令行模式的

    Synaptic

    由于synaptic是GUI界面的,没啥命令好说的,其实这个在Ubuntu里面也挺少用到的,更多的还是通过apt-get命令就可以搞定。

     

    需要熟记的:

           1). 查询vim是否安装:

    fbw@fbw-kylin:~$ dpkg -l | grep vim
    ii  vim                                         2:7.3.429-2ubuntu2.1                        Vi IMproved - enhanced vi editor
    ii  vim-common                                  2:7.3.429-2ubuntu2.1                        Vi IMproved - Common files
    ii  vim-runtime                                 2:7.3.429-2ubuntu2.1                        Vi IMproved - Runtime files
    ii  vim-tiny                                    2:7.3.429-2ubuntu2.1                        Vi IMproved - enhanced vi editor - compact version

     

    2). 查看python-six包的详情:

    fbw@fbw-kylin:/var/cache/apt/archives$ dpkg -s python-six
    Package: python-six
    Status: install ok installed
    Priority: optional
    Section: python
    Installed-Size: 53
    Maintainer: Colin Watson <cjwatson@debian.org>
    Architecture: all
    Source: six
    Version: 1.1.0-2
    Depends: python2.7, python (>= 2.7.1-0ubuntu2), python (<< 2.8)
    Description: Python 2 and 3 compatibility library (Python 2 interface)
     Six is a Python 2 and 3 compatibility library. It provides utility
     functions for smoothing over the differences between the Python versions
     with the goal of writing Python code that is compatible on both Python
     versions.
     .
     This package provides Six on the Python 2 module path. It is complemented
     by python3-six.

     

    PS:deb包对应的文件名为:"包名"_"Version"_"Architecture".deb

    3). apt-cache 查看包的详情:

     fbw@fbw-kylin:/var/cache/apt/archives$ apt-cache show python-six
    Package: python-six
    Priority: optional
    Section: universe/python
    Installed-Size: 53
    Maintainer: Colin Watson <cjwatson@debian.org>
    Architecture: all
    Source: six
    Version: 1.1.0-2
    Depends: python2.7, python (>= 2.7.1-0ubuntu2), python (<< 2.8)
    Filename: pool/universe/s/six/python-six_1.1.0-2_all.deb
    Size: 6062
    MD5sum: d934e809c17d748f15c1d989862bd7cd
    SHA1: 1ccffda8d00bb874a8163410e39c3f499a931b87
    SHA256: 12e087fb95a7f11185ac04b3cf49aa880d353d62b5dd8d043edf33ded265940e
    Description-en: Python 2 and 3 compatibility library (Python 2 interface)
     Six is a Python 2 and 3 compatibility library. It provides utility
     functions for smoothing over the differences between the Python versions
     with the goal of writing Python code that is compatible on both Python
     versions.
     .
     This package provides Six on the Python 2 module path. It is complemented
     by python3-six.
    Homepage: http://packages.python.org/six/
    Description-md5: cfd46d2babaaa95d96b4e170cd5bf348
    Bugs: https://bugs.launchpad.net/ubuntu/+filebug
    Origin: Ubuntu

  • 相关阅读:
    洛谷P4550 收集邮票 期望dp
    Codeforces Round #748 (Div. 3) G. Changing Brackets
    [Codeforces Round #748 (Div. 3)](https://codeforces.com/contest/1593) F. Red-Black Number 记忆化搜索
    [Codeforces Round #748 (Div. 3)](https://codeforces.com/contest/1593) D2 Half of Same
    HDU 3746 Cyclic Nacklace kmp找循环节
    Codeforces Round #747 (Div.2) D. The Number of Imposters
    Nand2tetris 学习笔记
    怎样解题表
    [省选]知识点板块
    List of Problems to be Solved
  • 原文地址:https://www.cnblogs.com/fbwfbi/p/3587159.html
Copyright © 2011-2022 走看看