-1

Hi there:) How do software updates differ based on the way I download software using ubuntu? For example when I download it manually using the apt-package manager, or when I add some repository to /etc/apt/sources.list. There is also the chance to download software using flatpacks or snaps.

What actually happens when I call sudo apt update? Which repositories get checked?

4 Answers 4

2

There are many ways to install software packages on Ubuntu, some of them you have not mentioned. In order to give a complete answer, I want to describe all of them:

Installation by package manager, default repositories

The package manager (no matter if apt, apt-get, aptitude or whatnot) has a list of locations to download software from. This software is generally trustworthy, known to work and mostly well maintained. Such a location is called a "repository". The repositories' URLs are stored in /etc/apt/sources.list. When running apt update, the package manager queries the repository so it knows which software packages are available. It stores the information in a local cache.

When installing a package by apt install, the package manager checks its local cache to determine where to download the package from. Then it downloads the package. The package is provided as an archive in the DEB format. The archive is unpacked into your local file-system. Additionally, the package may contain some code which will be automatically executed once for setting up the newly installed software.

When updating software by apt upgrade or apt dist-upgrade, new versions of existing packages are downloaded. The current version is removed from the system. The package manager knows which files to remove as it knows which file was provided by which package. The new version is then installed as described above.

Installation by package manager, custom repositories

It is also possible to expand upon the default repositories by adding URLs to /etc/apt/sources.list, although these days /etc/apt/sources.list.d/ should be used. The package manager will regard them just like the default repositories. Installing, removing and updating works exactly the same. The user must take care when adding custom repositories – they must be made for the system.
On a side-note: From personal experience, I advise to remove all packages installed from non-default repositories before doing an upgrade from one Ubuntu release to the next one.

Installation by package manager, manual download

You can also download DEB files manually. You can install the package via dpkg -i. The package manager will never update this package since it does not know where it came from.

Installation via snap

snapcraft is an alternative to the package manager geared towards being compatible not only with Debian-derived Ubuntu, but with all Linux distributions. A snap package is not unpacked into the system. Moreover it is mounted (its contents made visible directly) and the software is executed in a controlled environment inside your system (think of sandboxing and virtual machines). When removing a snap, the package is unmounted and removed. Updates happen analogous.

Fully manual installation

You can also download a bunch of files and place them in appropriate places on your hard-drive. Custom software often goes into /opt. Binaries (or links to them) are installed into a directory in $PATH. This way, the software can be accessed easily. The package manager does not know anything about this software. Updates need to be installed manually, too (sometimes the software features a self-update function, tough). Custom software can also be installed to places like /usr/local or even /usr. The latter should not be done unless you really know what you are doing. Custom software can clash horribly with software controlled by the package manager.

Similar questions:
Ubuntu software updates with apt-get
Does it make a difference whether I update packages via Apper or the Software Center in Debian?

1
  • Thank's a lot really for this answer!! Exactly what I hoped for. This will help me a lot in the future! Mar 21, 2020 at 15:37
1

I would suggest only installing software from the sources provided by your distributor. Only manually add repositories or install packages or other software manually if you exactly know what you are doing. As for the question what sudo apt update does: It's fetching the latest available packages from all you configured repositories. The same applies for snaps or flatpacks. Once you've installed them from a central repository, you'll get updates in a similar manner to apt update.

1

apt update updates the list of available packages from the repositories that are in /etc/apt/sources.list and in any files that are in /etc/apt/sources.list.d/. It is important to run this first so that apt knows about newer versions of packages.

apt upgrade actually upgrades the installed packages that have newer versions available provided that they were installed via apt and that the repositories from which they came are in the locations above.

Packages from snap and flatpak won't be upgraded by apt as the repositories are different and won't be in apt's cache/database.

1

apt update checks all your software sources, so this is the distro's repositories and any PPA you added. AFAIK this doesn't include flatpak (use flatpak update for this), but can include snap if this is how the distro installs it. Things that you installed manually (downloaded .deb or other installation means) are of course not checked that way.

But keep in mind that Ubuntu has its own update policy, part of the distro are updated until the distro's end-of-life ("main" repo), others receive little or no updates ("universe" repo and others)(and most snap-installed package are not in "main").

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .