I understand that in apt
, the command update
, updates the list of available packages, but it does not upgrade software that was already installed from these packages.
I also understand that upgrade
upgrades any software that I already installed from a package I updated with update
as described above.
What was the reason of the Ubuntu/Debian developers to do this splitting of update
and upgrade
instead work with one command to do both tasks?
This is more of a question on the architectural philosophy of the Ubuntu developers.
The history of the difference between
update
andupgrade
is actually pretty cool.Long, long ago --say around 2000 or so, years before Ubuntu existed--, bandwidth and disk space were much more limited...though expansive compared to mid-1990s. Broadband was just getting started, and dialup was still a vital way of getting online. Big disks were still only a few hundred MB. Apt was shiny and new, radical and revolutionary, built on top of dpkg.
The apt database, when you think about it, is a marvel: It's an accurate-to-the-minute database of all software from all known repositories. It's detailed enough for apt to calculate dependencies and identify available upgrades, yet small enough to transmit over the dial-up modems of the time and to store on the small drives of the time. Updating your database by phone might take minutes over a good connection. While that's a long time now, looking up package updates manually (before apt) could consume hours.
Back then, distros were built differently - no Continuous Integration, no smoke testing (well, not much testing at all!), build farms were just getting started. Upgrades had to be reverted more often than now. Many users chose to not upgrade certain packages for various reasons, or to select only certain upgrades today (to test manually), and other upgrades tomorrow.
Over the subsequent 15-or-so years, the tools have not changed much, which is why we still have separate
update
andupgrade
actions. The user workflow has evolved as distro reliability has improved, and much of the source/update/upgrade management that used to be manual has been slowly hidden behind layers of automation (software-updater
,unattended-upgrades
).Modernizing software package tools is one reason that Snaps and AppImage and Flatpack have recently appeared, but that's the next chapter.
An upgrade is not the only time you might need to
apt-get update
, and I do not want to upgrade each time I simply want to update the package lists.An
apt-get upgrade
working well may depend onapt-get update
being run not long ago, but then that is true ofapt-get remove
andapt-get install
as well! Should all of these implyapt-get update
? Of course not! As a simple matter of resource efficiency and design cleanness, if an operation is common to multiple other operations, it should be factored out.Conversely, given that
apt-get remove
andapt-get install
may also depend onapt-get update
being recently run to successfully finish, does it make sense toapt-get upgrade
for each run ofapt-get update
? No, again, since what I intend to do may well conflict with whatapt-get upgrade
will do.Whenever you change the software sources, you must run the command
sudo apt update
in order to refresh the list of available software. Then you can search for available packages in the new software source you just added and/or install them.The command
sudo apt upgrade
is the terminal equivalent of upgrading the list of installed packages using the Software Updater application. This is different from the normal workflow of adding a new software source, updating the list of available software to include packages from the new software source, and installing new package(s) from the new software source that you just added, so it's more convenient and less confusing thatsudo apt update
andsudo apt upgrade
are separate commands.It's also less confusing to separate
sudo apt update
andsudo apt upgrade
because when you runsudo apt update
successfully you have confirmed that you have internet connectivity. If there is a problem when runningsudo apt upgrade
afterwards, the problem is more likely to be a package management issue than an issue with internet connectivity, and the results ofsudo apt upgrade
will provide clues for diagnosing and solving the problem.They do separate things for many reasons.
One example is a question I posted and self-answered: How can PPAs be removed using GUI?. On this screen we want to remove PPAs not upgrade the software:
After removing a PPA the GUI software automatically runs
sudo apt update
. If you were to remove a PPA from the command line you need to runsudo apt update
after removing a PPA from sources list.Without a separate
apt update
function there is no way to remove a PPA!.Another example is you need to run
sudo apt update
from command line to refresh sources. Then you can find out what could be upgraded without actually upgrading:Looking at the output you could decide to have a given package "pinned" or "held back" and not upgraded the next time `sudo apt upgrade" is run. If there were a single "update/upgrade" process you would loose these ability.
Without a separate
apt update
you can't see what would be upgraded!One could ask why to download the program from the formal Ubuntu repository with
apt
then install it? What difference would it make if you first download it and then install it rather than downloading and installing in one operation?Well after reading the comments and thinking more on this I understand that this is due to the Unix philosophy, a modular philosophy that basically says "Each program does one thing": First download, then install --- each action with its own dedicated program.
In no distribution, there is one command update-upgrade thing, if it's there, it's nothing but predefined aliases as much I presume. Those aliases can easily be set on Ubuntu too, by editing the ~/.bashrc.
Update is used to resyncronize the repositories and fix any issues there. Then when you Upgrade, you actually ugrade your installed packages. But when you Dist-Upgrade, you upgrade in full. In Arch linux, they emphasise on full upgrade with Syu. You can do the same in Ubuntu. In full upgrade, you actually resolve any dependency issue system wise, that may arise in partial upgrade.
Hope it helps. Please excuse the raw text as writing on phone.