CrackOps
Interview PrepTracksLinuxAWS LabSoonInterview RoomSoon
Sign inStart free
CrackOps

Interview prep for the people who keep production up.

[email protected]
ProductInterview PrepTracksDashboardInterview Room
RolesDevOpsSREPlatformCloud
CompanyAboutContactPrivacyTerms
© CrackOps
Linux / Packages & Services / yum

yum

The classic RPM package manager (and what it is today)

Beginnerpackagesrhellegacy

yum installs and updates RPM packages on RHEL/CentOS 7 and Amazon Linux 2. On RHEL 8+, Amazon Linux 2023 and Fedora, the yum command still exists but is a symlink to dnf, so the same commands keep working everywhere in the Red Hat family.

Syntaxyum [OPTIONS] install | remove | update | check-update | search | info | whatprovides | list | history | clean [ARGS]...

Watch it run

A legacy Amazon Linux 2 host needs jq for a deploy script. Watch yum 3 resolve the dependency step by step.

devops@devops-lab: ~ — zsh — 96×28
➜ ~
Step 1 of 2
sudo yum install -y jq

yum 3 prints its dependency loop: jq needs the shared library libonig.so.2, which oniguruma provides, so it runs another transaction check. Dependencies are often libraries (sonames), not package names.

Anatomy of a command

$
commandsudo

Installing changes the RPM database and system files, so it needs root.

How it works

Classic yum is a Python 2 program on top of rpm. It reads /etc/yum.conf and the .repo files in /etc/yum.repos.d, downloads each repo's repomd.xml plus the primary and filelists metadata (SQLite files) into /var/cache/yum, and loads plugins such as priorities and fastestmirror. Its depsolver works in loops: mark the package, then repeatedly process unmet dependencies ('--> Processing Dependency') until everything is satisfied. Then it downloads the RPMs, checks their GPG signatures, runs an rpm test transaction and finally the real one. A single lock file, /var/run/yum.pid, stops two yum processes running at once. Transactions are recorded in /var/lib/yum/history so they can be listed and undone. On RHEL 8+ and AL2023, /usr/bin/yum is a symlink to dnf-3, so the output looks like dnf's, the solver is libsolv and yum.conf is really dnf.conf.

Options you'll actually use

install PKGInstall packages and dependencies
update [PKG]Update everything or the named packages (upgrade is the same in yum)
check-updateList updates; exit 100 if any
remove PKGRemove packages (and anything that depends on them)
search / infoFind packages by name or summary / show one package's details
whatprovides PATHWhich package ships a file (alias: provides)
list installedInstalled packages with version and source repo
history [info|undo N]Show, inspect or reverse past transactions
--enablerepo / --disablerepoToggle repos for this one command
--securityOnly security updates (yum-plugin-security / built in on AL2)
clean allDelete cached metadata and packages
-yAssume yes

Common mistakes

Assuming yum and dnf behave identically on RHEL 7

On RHEL/CentOS 7 and AL2, yum is the old Python 2 yum 3 with a different solver, output and options (no --setopt=install_weak_deps, for example).

Check: ls -l /usr/bin/yum; yum --version
sudo rm /var/run/yum.pid to get past the lock

Another yum is mid-transaction. Two writers can leave duplicate or half-installed packages in the rpmdb.

Wait, or find it: ps -o pid,args -p <pid>
yum update -y in a cron job on production

Every package moves, kernels included, with no review and no reboot plan.

yum update --security -y, or patch through a reviewed window
Looking for nginx with plain yum on Amazon Linux 2

It's in a disabled extras topic, so yum reports 'No package nginx available'.

sudo amazon-linux-extras install nginx1

Interview questions

Practice

Try these on a Linux machine of your own. Each task has a hint and a solution.

  1. 1

    The sandbox has no yum. Write the yum command that lists every available version of nginx.

  2. 2

    Read this output and say what happened: 'No package nginx available. Error: Nothing to do'. Which system printed it?

  3. 3

    In the sandbox, check whether a command is a symlink and to what, using /usr/bin/awk as the example (just like yum -> dnf-3).

Related commands

dnfManage packages on Amazon Linux 2023, RHEL and FedorarpmQuery, verify and install RPM packages directlyaptInstall, upgrade and remove packages on Debian and Ubuntu
PreviousdnfNextrpm
Linux / Packages & Services / yum

yum

The classic RPM package manager (and what it is today)

Beginnerpackagesrhellegacy

yum installs and updates RPM packages on RHEL/CentOS 7 and Amazon Linux 2. On RHEL 8+, Amazon Linux 2023 and Fedora, the yum command still exists but is a symlink to dnf, so the same commands keep working everywhere in the Red Hat family.

Syntaxyum [OPTIONS] install | remove | update | check-update | search | info | whatprovides | list | history | clean [ARGS]...

Watch it run

A legacy Amazon Linux 2 host needs jq for a deploy script. Watch yum 3 resolve the dependency step by step.

devops@devops-lab: ~ — zsh — 96×28
➜ ~
Step 1 of 2
sudo yum install -y jq

yum 3 prints its dependency loop: jq needs the shared library libonig.so.2, which oniguruma provides, so it runs another transaction check. Dependencies are often libraries (sonames), not package names.

Anatomy of a command

$
commandsudo

Installing changes the RPM database and system files, so it needs root.

How it works

Classic yum is a Python 2 program on top of rpm. It reads /etc/yum.conf and the .repo files in /etc/yum.repos.d, downloads each repo's repomd.xml plus the primary and filelists metadata (SQLite files) into /var/cache/yum, and loads plugins such as priorities and fastestmirror. Its depsolver works in loops: mark the package, then repeatedly process unmet dependencies ('--> Processing Dependency') until everything is satisfied. Then it downloads the RPMs, checks their GPG signatures, runs an rpm test transaction and finally the real one. A single lock file, /var/run/yum.pid, stops two yum processes running at once. Transactions are recorded in /var/lib/yum/history so they can be listed and undone. On RHEL 8+ and AL2023, /usr/bin/yum is a symlink to dnf-3, so the output looks like dnf's, the solver is libsolv and yum.conf is really dnf.conf.

Options you'll actually use

install PKGInstall packages and dependencies
update [PKG]Update everything or the named packages (upgrade is the same in yum)
check-updateList updates; exit 100 if any
remove PKGRemove packages (and anything that depends on them)
search / infoFind packages by name or summary / show one package's details
whatprovides PATHWhich package ships a file (alias: provides)
list installedInstalled packages with version and source repo
history [info|undo N]Show, inspect or reverse past transactions
--enablerepo / --disablerepoToggle repos for this one command
--securityOnly security updates (yum-plugin-security / built in on AL2)
clean allDelete cached metadata and packages
-yAssume yes

Common mistakes

Assuming yum and dnf behave identically on RHEL 7

On RHEL/CentOS 7 and AL2, yum is the old Python 2 yum 3 with a different solver, output and options (no --setopt=install_weak_deps, for example).

Check: ls -l /usr/bin/yum; yum --version
sudo rm /var/run/yum.pid to get past the lock

Another yum is mid-transaction. Two writers can leave duplicate or half-installed packages in the rpmdb.

Wait, or find it: ps -o pid,args -p <pid>
yum update -y in a cron job on production

Every package moves, kernels included, with no review and no reboot plan.

yum update --security -y, or patch through a reviewed window
Looking for nginx with plain yum on Amazon Linux 2

It's in a disabled extras topic, so yum reports 'No package nginx available'.

sudo amazon-linux-extras install nginx1

Interview questions

Practice

Try these on a Linux machine of your own. Each task has a hint and a solution.

  1. 1

    The sandbox has no yum. Write the yum command that lists every available version of nginx.

  2. 2

    Read this output and say what happened: 'No package nginx available. Error: Nothing to do'. Which system printed it?

  3. 3

    In the sandbox, check whether a command is a symlink and to what, using /usr/bin/awk as the example (just like yum -> dnf-3).

Related commands

dnfManage packages on Amazon Linux 2023, RHEL and FedorarpmQuery, verify and install RPM packages directlyaptInstall, upgrade and remove packages on Debian and Ubuntu
PreviousdnfNextrpm