一、包管理基本原理
Linux系统具有强大的包管理能力,能够自动从互联网的软件仓库中搜索、安装、升级、卸载软件或操作系统。其基本原理为:
root@linux:/var/lib/apt/lists$ cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic stable
# deb-src [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic stable
root@linux:/var/lib/apt/lists# ll
total 222044
drwxr-xr-x 4 root root 12288 Feb 7 10:17 ./
drwxr-xr-x 5 root root 4096 Nov 13 2020 ../
drwxr-xr-x 2 _apt root 4096 Nov 16 2020 auxfiles/
-rw-r----- 1 root root 0 Nov 16 2020 lock
-rw-r--r-- 1 root root 74562 Feb 7 07:11 mirrors.aliyun.com_ubuntu_dists_bionic-backports_InRelease
-rw-r--r-- 1 root root 59629 Dec 16 00:17 mirrors.aliyun.com_ubuntu_dists_bionic-backports_main_binary-amd64_Packages
-rw-r--r-- 1 root root 12910 Dec 16 00:17 mirrors.aliyun.com_ubuntu_dists_bionic-backports_main_i18n_Translation-en
-rw-r--r-- 1 root root 17863 Dec 16 00:17 mirrors.aliyun.com_ubuntu_dists_bionic-backports_main_source_Sources
-rw-r--r-- 1 root root 49624 Dec 16 02:14 mirrors.aliyun.com_ubuntu_dists_bionic-backports_universe_binary-amd64_Packages
-rw-r--r-- 1 root root 15723 Dec 16 02:14 mirrors.aliyun.com_ubuntu_dists_bionic-backports_universe_i18n_Translation-en
-rw-r--r-- 1 root root 20023 Dec 16 02:14 mirrors.aliyun.com_ubuntu_dists_bionic-backports_universe_source_Sources
-rw-r--r-- 1 root root 242048 Apr 27 2018 mirrors.aliyun.com_ubuntu_dists_bionic_InRelease
......
进一步,查看文件的信息,则:
root@linux:/var/lib/apt/lists# cat mirrors.aliyun.com_ubuntu_dists_bionic_InRelease | more
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Origin: Ubuntu
Label: Ubuntu
Suite: bionic
Version: 18.04
Codename: bionic
Date: Thu, 26 Apr 2018 23:37:48 UTC
Architectures: amd64 arm64 armhf i386 ppc64el s390x
Components: main restricted universe multiverse
Description: Ubuntu Bionic 18.04
MD5Sum:
32a92a5c20f378d42dd2d2f4f28f6637 628836439 Contents-amd64
53c6a594819b51a5755f88b45d1eff7f 37766986 Contents-arm64.gz
cd7bf6d50403da4348ee48138eace986 585939706 Contents-ppc64el
af42d07307c5d1398c75e28986b36509 616261664 Contents-i386
98f43960ac7029b4948a13614038593c 584794633 Contents-armhf
31848d4faedf11946ff1af9c281f4e6b 39528051 Contents-amd64.gz
root@linux:/var/lib/apt/lists# apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
grub-pc-bin
Use 'apt autoremove' to remove it.
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following packages will be upgraded:
git
1 upgraded, 0 newly installed, 0 to remove and 315 not upgraded.
root@linux:/var/lib/apt/lists# apt-get upgrade
......
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.
Processing triggers for initramfs-tools (0.130ubuntu3.13) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-122-generic
二、工具apt-get和apt区别:
apt命令 原有命令 命令的功能
apt install apt-get install 安装软件包
apt remove apt-get remove 移除软件包
apt purge apt-get purge 移除软件包及配置文件
apt update apt-get update 刷新存储库索引
apt upgrade apt-get upgrade 升级所有可升级的软件包
apt autoremove apt-get autoremove 自动删除不需要的包
apt full-upgrade apt-get dist-upgrade 在升级软件包时自动处理依赖关系
apt search apt-cache search 搜索应用程序
apt show apt-cache show 显示安装细节
全部0条评论
快来发表一下你的评论吧 !