CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
    • 1.Package Management (1): RPM and YUM
    • 2.Package Management (2): DEB, APT, and Source Installation
    • 3.Device Files and /dev
    • 4.Using Peripherals: Printers · Sound · Scanners
    • 5.Week 7 Comprehensive Review: Packages and Devices
  • Week 8
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 7/Day 1

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 7 · Day 1~20 min read

Day 1 - Package Management (1): RPM and YUM

📌 Key Takeaways

  • A package is a single file that bundles a program together with its installation info. The format differs by distribution.
  • Linux packages split into the RPM family (Red Hat, CentOS, Fedora, SUSE) and the DEB family (Debian, Ubuntu).
  • The tools come in two layers: the low-level tool (rpm) cannot resolve dependencies on its own, while the high-level tool (yum) can.
  • Memorize four rpm options: -i install, -U upgrade, -e erase, -q query.
  • DNF is the successor to YUM, and the SUSE family uses zypper.

What Is a Package

   package = executables + config files + docs + install info (dependency list)
  • In the past you had to download the source and compile it yourself. A package does that work in advance and distributes the result as a bundle.
  • Dependency — for a program to run, other libraries must be present first. The package records this relationship.
ProblemMeaning
Dependency problemInstallation is blocked because a required package is missing
Dependency hellTo install A you need B, to install B you need C... and it goes on endlessly

The Two Families

ItemRPM familyDEB family
Extension.rpm.deb
DistributionsRed Hat, CentOS, Fedora, SUSEDebian, Ubuntu, Mint
Low-level toolrpmdpkg
High-level toolyum, dnfapt, apt-get
  • Questions ask which distribution belongs to which family directly. It is in scope that Ubuntu is in the Debian family, so it uses .deb.
  • RPM originally stood for Red Hat Package Manager; today it is expanded as RPM Package Manager.

Low-Level vs. High-Level

   High-level (yum · dnf · apt)
      │  downloads from repositories and resolves dependencies automatically
      ▼
   Low-level (rpm · dpkg)
      │  just installs or removes the one file you give it
      ▼
   System
ItemLow-levelHigh-level
HandlesA single fileA repository
DependenciesCannot resolve them on its ownResolves them automatically
Examplesrpm, dpkgyum, dnf, apt

This distinction is the heart of this unit. If asked "Which tool resolves dependencies automatically?", the answer is the high-level tool (yum, apt).

rpm — The Low-Level Tool

rpm -ivh package.rpm      # install (install, verbose, hash)
rpm -Uvh package.rpm      # upgrade (installs if not present)
rpm -e package-name       # erase (erase)
rpm -qa                   # all installed packages (query all)
rpm -q package-name       # is that package installed?
rpm -ql package-name      # list of files the package installed (list)
rpm -qi package-name      # package info (info)
rpm -qf /path/file        # which package owns this file (file)
rpm -V package-name       # tamper check (verify)
OptionMeaning
-iInstall (install)
-UUpgrade — also installs if not present
-FUpgrade — only if already installed (freshen)
-eErase (erase)
-qQuery (query)
-v / -hVerbose / show progress (#)
--nodepsIgnore dependencies and force ahead
  • Difference between -i and -U — -U installs fresh if the package is absent, but -F updates only if it is already present.
  • rpm does not resolve dependencies. If a required package is missing, it prints an error and stops.
  • -v and -h only change how output is displayed, not what the command does. It is customary to combine three letters, as in -ivh and -Uvh.
  • Kernel packages are customarily installed with -i, not -U. -U removes the old version, so if the new kernel fails to boot, the old kernel you would fall back to is gone.

What the Screen Looks Like When Dependencies Block You

# rpm -ivh httpd-2.4.6-97.el7.x86_64.rpm
error: Failed dependencies:
        httpd-tools = 2.4.6-97.el7 is needed by httpd-2.4.6-97.el7.x86_64
        /etc/mime.types is needed by httpd-2.4.6-97.el7.x86_64
  • rpm only tells you what is missing and does not fetch it. Above, the httpd-tools package and a package that provides the /etc/mime.types file must be present first.
  • Removal is blocked the same way. Trying to remove something other packages rely on with rpm -e gives an is needed by (installed) … error.
ResponseCommandAssessment
Install the missing package firstrpm -ivh httpd-tools-….rpmThe orthodox way, but that package may require yet another one
Leave it to the high-level toolyum install httpdRecommended — it pulls the needed packages from the repository too
Ignore and force aheadrpm -ivh --nodeps file.rpmIt installs, but may not run
Force optionMeaning
--nodepsSkips the dependency check (for both install and erase)
--forceOverwrites and installs even if the package or files are already installed
--testDoes not actually install; only checks whether there would be a problem

Install Takes a File Name, Erase Takes a Package Name

# rpm -q httpd
httpd-2.4.6-97.el7.x86_64
# rpm -e httpd-2.4.6-97.el7.x86_64.rpm
error: package httpd-2.4.6-97.el7.x86_64.rpm is not installed
# rpm -e httpd
# rpm -q httpd
package httpd is not installed
TaskWhat you passWhy
Install -i · upgrade -U -FPackage file (….rpm)It is not on the system yet, so you must hand over the file
Erase -e · query -q · verify -VPackage name (httpd)Refers to something already installed and registered in the RPM database
Query -qpPackage fileLooks inside a file before it is installed
  • Information about installed packages is recorded in the RPM database (/var/lib/rpm). The rpm -q family reads this database.
  • When rpm -e succeeds, it prints nothing. Silence means it worked.

The Letters After -q

OptionWhat it asksArgument
-qaAll installed packages (all)None
-qiPackage info — version, description, install time (info)Package name
-qlList of files the package installed (list)Package name
-qcOnly the config files among them (config)Package name
-qdOnly the doc files among them (doc)Package name
-qfThe package that owns this file (file)File path
-qRWhat the package requires (requires)Package name
-qpTargets a file before installation — combine as -qpi, -qpl.rpm file
# rpm -qa | grep httpd
httpd-2.4.6-97.el7.x86_64
httpd-tools-2.4.6-97.el7.x86_64
# rpm -qf /etc/httpd/conf/httpd.conf
httpd-2.4.6-97.el7.x86_64
  • -ql and -qf point in opposite directions. -ql goes package → files, and -qf goes file → package. Questions put the two side by side in the choices.
  • -qa prints hundreds of lines, so you usually filter it with grep. With -q alone you must know the exact name, but -qa | grep finds a package from just part of the name.

Reading -V Verification

# rpm -V httpd
S.5....T.  c /etc/httpd/conf/httpd.conf
  • It compares the file now against the values recorded at install time. No output means nothing has changed.
  • A letter in a position marks the item that differs — S size, 5 content (hash value), T modification time, M permissions, U owner, G group. A dot (.) means unchanged.
  • The c in the middle means the file is a config file. Admins are expected to edit config files, so the result above is not a problem. A 5 on an executable is something to suspect.

Reading a Package File Name

   httpd - 2.4.6 - 97 . el7 . x86_64 . rpm
     │       │      │     │      │      │
     │       │      │     │      │      └── extension
     │       │      │     │      └───────── architecture (x86_64, i386, noarch)
     │       │      │     └──────────────── distribution (el7 = RHEL 7)
     │       │      └────────────────────── release number
     │       └───────────────────────────── version
     └───────────────────────────────────── package name
  • Questions ask about the name-version-release.architecture.rpm structure directly.
  • noarch means a package independent of CPU architecture (docs, scripts).
  • The version is the edition number of the program itself, and the release is how many times the distribution has repackaged that same version. If the program stays the same and only a security patch is added and reissued, only the release goes up.
  • Some package names contain hyphens. httpd-tools-2.4.6-97.el7.x86_64.rpm is read from the right — strip the architecture, release (97.el7), and version (2.4.6), and what remains, httpd-tools, is the name.
Architecture slotMeaning
x86_6464-bit Intel/AMD
i386 · i68632-bit Intel family
noarchIndependent of architecture
srcSource package before compilation (.src.rpm)

yum — The High-Level Tool

yum install httpd          # install (dependencies automatic)
yum remove httpd           # remove
yum update                 # update everything
yum update httpd           # only a specific package
yum list installed         # installed list
yum search keyword         # search
yum info httpd             # info
yum repolist               # repository list
yum clean all              # clean cache
  • It downloads what it needs from a repository on its own and installs the dependency packages together.
  • Repository settings live in .repo files under /etc/yum.repos.d/.

Reading a Repository Config File

# /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EntryMeaning
[base]The repository ID. One bracketed block is one repository
nameHuman-readable description
baseurlThe repository address to fetch packages from
enabled1 = in use, 0 = off
gpgcheckIf 1, checks the signature of packages
gpgkeyLocation of the public key used for the check
LocationRole
/etc/yum.confGlobal YUM settings
/etc/yum.repos.d/*.repoPer-repository settings
/var/cache/yumCache of downloaded lists and packages — emptied by yum clean all
/var/log/yum.logLog of installs and removals
  • The file name must end in .repo to be read. To turn a repository off temporarily, you do not need to delete the file; just change it to enabled=0.

Other Subcommands

CommandWhat it does
yum check-updateOnly checks whether there is anything to update
yum localinstall file.rpmInstalls a file you already downloaded, filling in dependencies from the repository
yum provides /path/fileFind the package that provides that file
yum grouplist · groupinstallView · install a bundle (group) of packages
yum eraseSame as remove
yum historyHistory of operations so far
yum -y install httpdAnswers yes to everything — proceeds without confirmation

rpm and yum Side by Side

Taskrpmyum
Installrpm -ivh file.rpmyum install name
Upgraderpm -Uvh file.rpmyum update name
Removerpm -e nameyum remove name
Installed listrpm -qayum list installed
Inforpm -qi nameyum info name
Which package owns a filerpm -qf fileyum provides file
DependenciesYou handle themAutomatic
Where the material comes fromThe file I hand overThe repository
  • rpm gives instructions with options (hyphen + letter), while yum uses English words. In the choices, mixed notations such as yum -i or rpm install are wrong.
  • yum also ends up installing RPM packages internally. That is why things installed with yum show up in rpm -qa as they are. The two are not rivals but upper and lower layers.
ToolWhere it is used
yumCentOS 7, RHEL 7 and earlier
dnfSuccessor to YUM — Fedora, RHEL 8 and later
zypperSUSE family
  • dnf has nearly the same command structure as yum. You use it as in dnf install.
  • A trap that appears: SUSE is in the RPM family, but its tool is zypper.
  • DNF stands for Dandified YUM. On RHEL 8 and later the yum command still exists, but it is really just a name that calls dnf.
  • zypper is used similarly — zypper install, zypper remove, zypper update.
SymptomCauseCheck / fix
Install stops with Failed dependenciesLow-level tools cannot resolve dependenciesInstall with yum install
rpm -e file.rpm says is not installedRemoval uses the package namerpm -e httpd
rpm -q says is not installed though you definitely installed itThe name is not exactFilter rpm -qa with grep
yum install cannot find the packageNo repository holding that package exists or it is offyum repolist, enabled in the .repo
You want to know if a config file was edited—rpm -V package-name

Tomorrow we cover the Debian family's dpkg and apt, and how to compile source yourself.

📖 Glossary

  • Package: A distribution unit that bundles program files and installation info into one.
  • Dependency: The relationship with other packages that a package needs in order to work.
  • RPM family: The family of distributions that use .rpm. Red Hat, CentOS, Fedora, SUSE.
  • Low-level tool: A tool that handles a single package file and does not resolve dependencies. rpm, dpkg.
  • High-level tool: A tool that uses repositories and resolves dependencies automatically. yum, dnf, apt.
  • Repository: A server that holds packages. Configured in /etc/yum.repos.d/.
  • dnf: The next-generation package management tool that replaced YUM.
  • zypper: The high-level package management tool used in the SUSE family.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which of the following distributions uses the .rpm package format?

Question 2

Which option of the rpm command is used to remove a package?

Question 3

Which of the following tools resolves dependency problems automatically and downloads and installs packages from a repository?

Question 4

In httpd-2.4.6-97.el7.x86_64.rpm, what does x86_64 represent?

Question 5

Which of the following is the high-level package management tool used on SUSE Linux?

PreviousWeek 6 Comprehensive Review: Editors and ProcessesWeek 6 · Day 5Next Package Management (2): DEB, APT, and Source InstallationWeek 7 · Day 2

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • What Is a Package
  • The Two Families
  • Low-Level vs. High-Level
  • rpm — The Low-Level Tool
  • What the Screen Looks Like When Dependencies Block You
  • Install Takes a File Name, Erase Takes a Package Name
  • The Letters After `-q`
  • Reading `-V` Verification
  • Reading a Package File Name
  • yum — The High-Level Tool
  • Reading a Repository Config File
  • Other Subcommands
  • rpm and yum Side by Side
  • Glossary
  • Practice Questions