0

Here: apt-get update updates all the packages? was a good question that IMO was neither a duplicate question nor sufficiently clearly answered... So let me guess the answer & perhaps someone can confirm or not. I suspect apt/apt-get update (a) reads (eg with dpkg --get-selections or --list) the list of installed items on the user's system, & then (b) conducts a search of the repo(s) the user has nominated in the 'sources' file(s) - looking for, & downloading the details of, just those items corresponding to list (a) where the repo has a more recent version. Of course, it would not be able to find items that were not on the repo eg where the user has installed from somewhere else.

ozwi
  • 1
  • apt-get update only updates your software lists, ie. packages that should be available and can be downloaded, are the latest etc. It does NO upgrades of packages at all; as upgrade, full-upgrade & dist-upgrade do that role. Yes apt-get update is limited to sources found in /etc/apt/sources.list & files within /etc/apt/sources.list.d/ but it does not upgrade any packages. apt-get update also does not look at whatever packages you have installed; it's only touching software lists of what's available. – guiverc Feb 16 '20 at 06:05
  • I'm aware it doesn't do any package upgrades but I had assumed it would only be able to generate a list of potential upgrades (or upgradable packages) by taking into account the packages (& their versions) that are currently installed. Else, surely details of everything on the repo would need to be downloaded & the filtering would only occur when upgrade was executed. (which would seem inefficient) – ozwi Feb 16 '20 at 08:10
  • It grabs software lists; so you can apt install new-program and it knows it's available too, ie. it isn't limited to whatever is pre-installed, and updates all software lists found in your sources.list files. apt-get doesn't look at any upgrades available, it doesn't care as it's not it's job. apt however does look & provides notice of whatever upgrades are available (apt update still doesn't really take longer, as it can do multiple things in parallel better than apt-get did, this extra task it performs shouldn't take longer - results however can vary) – guiverc Feb 16 '20 at 11:37
  • Thanks for your explanation @guiverc - looks like I guessed wrong about how this works. – ozwi Feb 17 '20 at 02:56
  • If you're happy with my answer, you can accept it. You're most welcome to wait for a better explanation (if one comes) too... fyi: the unix philosophy was each tool does one job only, and does it really well. Parts of GNU/Linux no longer really follow the unix one-job-well philosophy* (systemd probably comes to mind) but parts do. – guiverc Feb 17 '20 at 04:32

1 Answers1

2

apt-get update only updates your software lists, ie. packages that should be available and can be downloaded, are the latest etc. It does NO upgrades of packages at all; as upgrade, full-upgrade & dist-upgrade do that role.

Yes apt-get update is limited to sources found in /etc/apt/sources.list & files within /etc/apt/sources.list.d/ but it does not upgrade any packages. apt-get update also does not look at whatever packages you have installed; it's only touching software lists of what's available.

If you're using a badly outdated mirror; which can lead to package problems, it won't know or check for that (the output from the apt-get update can be useful to check https://launchpad.net/ubuntu/+archivemirrors yourself for those problems).

From man apt-get

   update
       update is used to resynchronize the package index files from their sources. The indexes of available packages
       are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive,
       this command retrieves and scans the Packages.gz files, so that information about new and updated packages is
       available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the
       overall progress meter will be incorrect as the size of the package files cannot be known in advance.

Note: This was copied from my 20.04 system, if you use man apt-get on your own box you'll see the reference manual page that perfectly matches your release.

guiverc
  • 30,396