RPM and DNF package management, and virtual guests
RPM-based package management: rpm for local package files and queries, dnf or yum for repositories, and the query flags that are worth memorising because they are asked verbatim.
Lesson 5 of 6 in objective 102. Linux installation and package management, part of LPIC-1 Exam 101-500.
rpm, and the query flags
rpm is to the Red Hat family what dpkg is to Debian: it installs a package file, removes an installed package, and answers questions about both. rpm -i installs, rpm -U upgrades or installs if absent, rpm -F upgrades only if an older version is already present, and rpm -e erases. The -v and -h flags add verbosity and a progress bar, which is why rpm -ivh appears in every example ever written.
The query mode is where the marks are. rpm -qa lists everything installed, rpm -qi shows a package's metadata, rpm -ql lists its files, rpm -qf tells you which package owns a file, and rpm -qp applies any of those to an uninstalled .rpm file instead. rpm -V verifies an installed package against the database and reports which files have changed since installation — the fastest honest answer to "has this been tampered with".
rpm2cpio converts a package into a cpio archive, which is how you extract files from an .rpm without installing it.
dnf and yum, and where repositories are declared
dnf is the current front end on Fedora and RHEL, yum the older one it replaced, and the command vocabulary is deliberately the same: install, remove, update, search, info, list, provides. Repositories are declared as .repo files in /etc/yum.repos.d/, each naming a base URL and whether it is enabled. dnf repoquery answers the questions rpm -q answers, but against repositories rather than what is installed.
zypper is the equivalent on SUSE, over the same RPM database. Its subcommands read differently — zypper in, zypper rm, zypper se — and it is worth recognising them even though the paper leans on dnf and yum.
Worth carrying in
- rpm -ivh file.rpm
- Install, verbose, with a progress bar.
- rpm -Uvh file.rpm
- Upgrade, installing the package if it is not already present.
- rpm -qa
- Every installed package.
- rpm -qf /path/file
- Which package owns this file.
- rpm -ql pkg
- Every file this package installed.
- rpm -V pkg
- Verify installed files against the package database.
- rpm2cpio
- Turn a package into a cpio stream so files can be extracted without installing.
- /etc/yum.repos.d/
- One .repo file per repository.
- dnf provides /path
- Which package in the repositories would supply this file.
What the exam does with this
rpm-U installs when the package is absent;rpm-F does not. That single difference is a question on its own.- Adding -p to a query makes it apply to a package FILE rather than to something installed.
rpmdoes no dependency fetching. Anything about resolving dependencies from repositories isdnf, yum or zypper.
- Objective
- 102. Linux installation and package management
- Share of the exam
- 18.33% (the whole objective)
- Questions in this lesson
- 15
- Signed for by a person
- 0
Partly checked. None of the 15 questions here has been read against the cited source by a person. 15 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise RPM and DNF package management, and virtual guests
Questions in this lesson
- On an RPM-based system you have a set of .rpm files and you want to upgrade only those packages that are already installed, leaving the rest untouched. Which rpm option does exactly that? machine-checked
- On an RPM-based system, type the rpm command that reports which installed package owns the file /usr/bin/ssh. machine-checked
- You need to pull one configuration file out of an .rpm package without installing the package. Which approach works? machine-checked
- On a Red Hat family system using dnf, which command finds out which package provides the command /usr/bin/semanage, including packages that are not yet installed? machine-checked
- You have downloaded httpd-2.4.57-5.el9.x86_64.rpm but have not installed it, and you want to see exactly which files it would place on the system. Which command lists them? machine-checked
- Investigating a suspected change, you run `rpm -V openssh-server` and one line of output reads `S.5....T. c /etc/ssh/sshd_config`. What does that line say about the file? machine-checked
- `rpm -e libfoo` refuses to run and reports 'Failed dependencies: libfoo.so.1()(64bit) is needed by (installed) barapp-2.1-3.el9.x86_64'. Which response removes libfoo while leaving the system consistent? machine-checked
- Type the rpm command, with its options but with no package name, that lists every package currently installed on the system. machine-checked
- On an openSUSE server you need to see which software repositories are configured, with their aliases and whether each one is currently enabled. Which zypper command shows that? machine-checked
- You have pointed a SUSE machine's repositories at the next distribution release and now want the whole installed package set brought into line with those repositories, allowing packages to be downgraded, replaced by a differently named successor or removed where necessary. Which zypper command performs that kind of upgrade? machine-checked
- The file /etc/yum.repos.d/epel.repo defines a repository with the alias 'epel' and the setting enabled=0. You need to install the package 'htop' from it once, without leaving the repository switched on for future transactions. Which command does that? machine-checked
- A colleague has just published a newer build of an internal package to your local yum repository, but on the client `yum list available` still shows only the old version. Which command makes the client discard its cached repository metadata so the next transaction fetches it again? machine-checked
- Before removing an installed package you want to see the list of capabilities and shared libraries that this package itself depends on. Which rpm query prints that? machine-checked
- You downloaded a vendor package and ran `rpm -K vendor-agent-3.2-1.x86_64.rpm`, which reported the digests as OK but the signature as NOKEY. What should you do to complete the verification? machine-checked
- Which THREE of the following statements about package management on an RPM-based system are correct? machine-checked
Practise RPM and DNF package management, and virtual guests
The rest of objective 102
- Planning a disk layout
- Installing and configuring a boot manager
- Shared libraries and the dynamic linker
- Debian package management
- RPM and DNF package management, and virtual guests — you are here
- Running Linux as a virtualization guest