Packages
Files, plus a record of what they need and where they went
A package holds files, metadata such as version and dependencies, install scripts and a signature.
Linux software arrives as packages. This is nginx for Ubuntu: half a megabyte to download. Inside are the files it puts on disk: the program, its manual page, its service unit. Then metadata: its exact version and what it depends on. And scripts that run around installation, all signed by the distribution. Because the package manager records every file, it can upgrade or remove the package cleanly, and tell you which package owns any file.
Repositories
A signed index the package manager trusts
A repository publishes signed indexes and packages; apt update fetches the indexes and checks the signature.
Packages come from repositories. A repository publishes a signed list of indexes, the indexes themselves, and the package files. apt update downloads the indexes and checks their signatures against keys you trust. It installs nothing. apt install then resolves, downloads, verifies and installs. The sources file names the address, the suites and the key. On Red Hat, the same lives in files under yum dot repos dot d.
Dependencies
Ask for one package, receive the tree it needs
The package manager resolves dependencies and installs only the missing ones; autoremove clears them later.
Here is what actually happened when this server was asked for nginx. nginx itself, which needs its common files, the iproute2 tools and a TLS library. iproute2 needs two more libraries. The TLS library and the C library were already installed, so they are left alone. Five new packages in all, worked out in a fraction of a second. Doing this by hand is how servers end up broken.
apt and dnf
Two families of tools, the same ten verbs
apt and dpkg on Debian and Ubuntu, dnf and rpm on Red Hat: high-level tools resolve, low-level ones query.
The two big families do the same jobs with different words. Install, remove and update are almost identical. The low-level tools, dpkg and rpm, answer questions about what is installed: which package owns a file, and which files a package installed. And dnf keeps a history you can undo. Learn the table once, and either kind of server is familiar.
apt and dnf · Going deeper · 1 of 3
Five lines in /etc/yum.repos.d add a repository
A .repo file names the repository, its baseurl and its GPG key; BaseOS and AppStream are RHEL’s two main ones.
On Red Hat systems, a repository is a small file. A section name in brackets, a readable name, the base URL where packages live, enabled, and gpg check with the key to check against. dnf repolist shows it working. The Red Hat exam gives you a URL and expects you to write exactly this. On a real RHEL machine, BaseOS and AppStream come from your subscription.
apt and dnf · Going deeper · 2 of 3
Desktop apps from their own remotes, in a sandbox
Flatpak installs sandboxed applications and shared runtimes from remotes such as Flathub, separately from system packages.
Flatpak is a second way to install software, used for desktop applications. Each app runs in a sandbox and brings its libraries as a shared runtime, so it never touches the system’s own packages. Apps come from remotes, such as Flathub. You add a remote, install, list, run and uninstall. RHEL ten includes it, and the Red Hat exam now asks you to configure a Flatpak remote and install from it.
apt and dnf · Going deeper · 3 of 3
Compile it yourself only when there is no package
configure, make and make install build into /usr/local, with no tracking, dependencies or security updates.
Sometimes software has no package, and you build it. Configure checks the system and writes a build plan, make compiles, and make install copies the results into user local. But nothing records those files, nothing installs what the build needed, and nothing will ever deliver a security fix. Treat it as the last resort, keep it out of the system’s own directories, and prefer a package or a container image.
Updates
Patch on a schedule, and keep the last kernel
Kernels install side by side; libraries need restarts and kernels need reboots; dnf-automatic or unattended-upgrades automate it.
Updates are routine maintenance. New kernels are installed beside the old ones, never over them; the newest boots by default and the older ones stay as a fallback. You can apply security fixes only, automate updates, check whether a reboot is needed, and hold a package at a version you have tested. A patched library does nothing until the programs using it restart.
Lab
Install, trace and remove on both families
apt and dnf side by side: simulate, install, find a file’s owner, add a repository by hand, install a Flatpak, remove cleanly.
In this lab you install and remove the same software on Ubuntu and on a Red Hat rebuild, trace files back to packages, write a repository file by hand, and install an application with Flatpak. Press the down arrow for the steps.
Lab · Going deeper
Install, trace and remove software on both families
Do steps 1 to 4 on Ubuntu and 5 to 8 on AlmaLinux or Rocky Linux 10. Both are free and close to what the exams use.
Do steps 1 to 4 on Ubuntu and 5 to 8 on AlmaLinux or Rocky Linux 10. Both are free and close to what the exams use. Steps. Read the plan. apt-get install --simulate nginx. Which packages are new? Compare with apt-cache depends nginx. Install and trace. sudo apt install nginx; dpkg -L nginx; dpkg -S /etc/nginx/nginx.conf; systemctl status nginx. Find the sources. cat /etc/apt/sources.list.d/ubuntu.sources. Name the suites and the key file. Run apt policy nginx to see which repository won. Remove it. sudo apt purge nginx nginx-common; sudo apt autoremove. What is the difference between remove and purge? Same on RHEL. sudo dnf install nginx; rpm -qf /usr/sbin/nginx; rpm -ql nginx | head; dnf history; dnf history undo last. Add a repository. Write /etc/yum.repos.d/local.repo pointing at a mounted install image (baseurl=file:///mnt/BaseOS, gpgcheck=1 with the key in /etc/pki/rpm-gpg). Check with dnf repolist. Install a local file. dnf download tree; sudo dnf install ./tree-*.rpm; rpm -qi tree. Then rpm -e tree. Flatpak. flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo; flatpak install flathub org.gnome.Calculator; flatpak list; flatpak uninstall it. Check: You can name the package that owns any file you are shown, on either family, and dnf repolist lists the repository you wrote by hand.
Steps
- Read the plan. apt-get install --simulate nginx. Which packages are new? Compare with apt-cache depends nginx.
- Install and trace. sudo apt install nginx; dpkg -L nginx; dpkg -S /etc/nginx/nginx.conf; systemctl status nginx.
- Find the sources. cat /etc/apt/sources.list.d/ubuntu.sources. Name the suites and the key file. Run apt policy nginx to see which repository won.
- Remove it. sudo apt purge nginx nginx-common; sudo apt autoremove. What is the difference between remove and purge?
- Same on RHEL. sudo dnf install nginx; rpm -qf /usr/sbin/nginx; rpm -ql nginx | head; dnf history; dnf history undo last.
- Add a repository. Write /etc/yum.repos.d/local.repo pointing at a mounted install image (baseurl=file:///mnt/BaseOS, gpgcheck=1 with the key in /etc/pki/rpm-gpg). Check with dnf repolist.
- Install a local file. dnf download tree; sudo dnf install ./tree-*.rpm; rpm -qi tree. Then rpm -e tree.
- Flatpak. flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo; flatpak install flathub org.gnome.Calculator; flatpak list; flatpak uninstall it.
Lesson complete
You finished “Installing software”
Nicely done.