apt

一般来说著名的 Linux 系统基本上分两大类:

RedHat 系列:Redhat、Centos、Fedora 等
Debian 系列:Debian、Ubuntu 等

  • Dpkg (Debian系):Ubuntu
  • RPM (Red Hat系):CentOS、Fedora

虽然RPM与DPKG有效的解决的软体的安装,移除与查询的需求。
但是在Linux上的套件管理还有一个很大的问题必须解决,就是各软体间的相依性(dependency)。
RPM与DPKG只能做到检查相依性,在安装或移除时告知相依性的不满足,皆下来就需要使用者自行去找出所需的套件来安装。
这样的确是有点不方便,因此产生了前端工具软体- APT及YUM。

apt

资料: https://www.digitalocean.com/community/tutorials/ubuntu-and-debian-package-management-essentials

update

  • source list
    sudo apt-get update

  • packages
    sudo apt-get upgrade

    sudo apt-get dist-upgrade

    it is a good idea to keep an eye on the packages to be r emoved, just in case some essential components are marked for removal.

download and install

sudo apt-get install -y package1 package2=version

  • fix broken
    sudo apt-get install -f

    One common scenario where this may happen is when installing a .deb package with dpkg, which does not resolve dependencies.

  • simulate (模仿)
    apt-get install -s package
    apt-get -s dist-upgrade

  • download

    This will download the specified package(s) to the current directory.

    apt-get download package

    sudo apt-get source package

    To download the source of a package, you must have a corresponding deb-src line in your source.list file for apt.

source package:

  1. a dsc description file

  2. a package directory

  3. the tarred and compressed package

install

sudo dpkg --install debfile.deb

sudo apt-get install -f

configure

sudo dpkg-reconfigure package

dpkg-reconfigure bash 设置默认的shell为bash

  • find package
    apt-cache search package

    Any search preformed will look at the package names, as well as the full descriptions for packages.

  • version
    apt-cache policy package

  • deb-src
    sudo apt-cache showsrc xxx

uninstall

sudo apt-get remove package

This command leaves configuration files

sudo apt-get purge package

remove a package and all associated files

  • dependency
    sudo apt-get autoremove
    sudo apt-get --purge autoremove

    remove all of the associated configuration files from the dependencies being removed

  • .deb

APT 底層包的是 dpkg, 而 dpkg 安裝 Package 時, 會將 *.deb 放在 /var/cache/apt/archives/ 如果需要重装Ubuntu时,可以把备份还原回去。这样就不能连上网络去大量更新系统软件包了

sudo apt-get autoclean
cleans obsolete deb-packages

sudo apt-get clean

info

apt-cache show package

dependency and reverse dependency

apt-cache showpkg package

apt-cache depends package

apt-cache rdepends package
reverse dependency: 反向依赖(谁需要我

.deb Package

dpkg --info debfile.deb
The target of this command should be the path to a .deb file

installed packages

dpkg -l

dpkg -l libyaml* dpkg will list all packages (whether installed or not) that contain that pattern

dpkg --get-selections

provides a list of all of the packages installed or removed but not purged

dpkg --get-selections libz*

search installed packages

Files Installed by a Package
package -> file

dpkg -L package

This will not include any configuration files that are generated by processes within the package 可以找到包的安装路径

file -> package

dpkg -S /path/to/file

any files that are moved into place by post installation scripts cannot be tied back to the package with this technique

Find Which Package Provides a File Without Installing It
sudo apt-get install apt-file
sudo apt-file update
sudo apt-file search /path/to/file

直接下载而来

Transferring Package Lists Between Systems

不同系统之间的进行安装包列表的export和import

repository

  • PPA

  • Add Repositories

apt tool
apt-get

update the local cache, and to make modifications to the live system.

apt-cache

query information about the available packages and their properties.

posted @ 2020-02-27 15:29  friedCoder  阅读(184)  评论(0)    收藏  举报