apt update VS apt-get update

apt update VS apt-get update

多年来,我一直认为apt update和的结果apt-get update是相同的。顺便说一句 - 是的,我知道apt并且apt-get不完全相同。

我最近注意到,一旦我apt update在我的 Ubuntu 机器上运行,它会检查 13 个源,但apt-get update只检查 7 个源。/etc/apt/sources.list此外,下面列出了总共 7 个更新源/etc/apt/sources.list.d/*

我在网上找不到任何有关此的信息。周围有人能给我解释一下吗?

***编辑这是我的 Mint 盒子的类似输出。它表现出相同的行为。我可能错过了一些东西,但不确定它是什么。

pcko@MBP12:~$ sudo apt update
[sudo] password for pcko:     
Ign:1 http://packages.linuxmint.com una InRelease
Hit:2 http://packages.linuxmint.com una Release                                
Hit:4 http://packages.microsoft.com/repos/code stable InRelease                
Hit:5 http://archive.canonical.com/ubuntu focal InRelease                      
Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease              
Get:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,745 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [277 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [918 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.6 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [390 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.3 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B]
Get:17 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [7,980 B]
Get:18 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.8 kB]
Get:19 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 3,816 kB in 2s (1,574 kB/s)                                          
Reading package lists... Done
Building dependency tree       
Reading state information... Done
211 packages can be upgraded. Run 'apt list --upgradable' to see them.

pcko@MBP12:~$ sudo apt-get update
Ign:1 http://packages.linuxmint.com una InRelease
Hit:2 http://packages.linuxmint.com una Release                                                                                                              
Hit:3 http://packages.microsoft.com/repos/code stable InRelease                                                                                              
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease                                                                                                       
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease                                             
Hit:7 http://archive.canonical.com/ubuntu focal InRelease                                          
Hit:8 http://archive.ubuntu.com/ubuntu focal-updates InRelease               
Hit:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done

pcko@MBP12:~$ cd /etc/apt
pcko@MBP12:/etc/apt$ ls
apt.conf.d  auth.conf.d  preferences.d  sources.list  sources.list.d  trusted.gpg.d

pcko@MBP12:/etc/apt$ cat sources.list
#deb cdrom:[Linux Mint 20.3 _Una_ - Release amd64 20220104]/ focal contrib main

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

pcko@MBP12:/etc/apt$ cd sources.list.d/
pcko@MBP12:/etc/apt/sources.list.d$ ls
official-package-repositories.list  vscode.list

pcko@MBP12:/etc/apt/sources.list.d$ cat official-package-repositories.list 
# Do not edit this file manually, use Software Sources instead.

deb http://packages.linuxmint.com una main upstream import backport #id:linuxmint_main

deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ focal partner

pcko@MBP12:/etc/apt/sources.list.d$ cat vscode.list 
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main

答案1

经过进一步研究,我同意@muru的评论是准确的:

请注意,如果 apt 发现现有信息是最新的,则不会进行完整检查(我不记得检查的确切机制,可能是标头提供的时间戳)。无论如何,如果您多次尝试此操作,但更改顺序,您会发现通常运行的第一个命令会下载更多文件,无论是哪个文件。

相关内容