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.

An rpm query, one letter at a time. rpm -qlp package.rpm — part 1, -q: query mode: ask rather than install; part 2, l: list the files (i for info, f for owner); part 3, p: ask a package FILE, not the installed database; part 4, package.rpm: the file, because of the p above. rpm 1 -q 2 l 3 p 4 package.rpm 1 query mode: ask rather than install 2 list the files (i for info, f for owner) 3 ask a package FILE, not the installed database 4 the file, because of the p above
An rpm query, one letter at a time.

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.

The two upgrade flags agree, until the package is not installed at all. rpm -U — An older version is installed: Upgrades it; The package is absent: Installs it. rpm -F — An older version is installed: Upgrades it; The package is absent: Does nothing rpm -U rpm -F An older version is installed Upgrades it Upgrades it The package is absent Installs it Does nothing
The two upgrade flags agree, until the package is not installed at all.

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.

The same three jobs, and what dnf, yum and zypper each call them. Left column, What you type; right column, The job it names. dnf install, yum install and zypper in all point at Install a package (Dependencies fetched with it, which rpm -i never does). dnf remove, yum remove and zypper rm all point at Remove an installed package. dnf search, yum search and zypper se all point at Search the repositories (For dnf and yum, one .repo file per repository under /etc/yum.repos.d/). What you type The job it names dnf install yum install zypper in Install a package Dependencies fetched with it, which rpm -i never does dnf remove yum remove zypper rm Remove an installed package dnf search yum search zypper se Search the repositories For dnf and yum, one .repo file per repository under /etc/yum.repos.d/
The same three jobs, and what dnf, yum and zypper each call them.

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

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

Practise RPM and DNF package management, and virtual guests

The rest of objective 102