Skip to content

OS patching (VMs): RHEL / AL2023

RHEL / AL2023 commands from the OS patching (VMs) folder.

Index
18 items

RHEL / AL2023: List pending updates

Safe

What would be upgraded. Exit code 100 = updates exist, 0 = none.

sudo dnf check-update
What each part does
  1. dnf check-updaterefresh metadata and list newer packages (yum check-update on RHEL 7)
  • #rhel
  • #packages

Also known as: check-update · pending updates

RHEL / AL2023: List pending security updates

Safe

RHSA / RLSA / ELSA advisories that apply to this VM.

sudo dnf updateinfo list --security
What each part does
  1. dnf updateinfo listadvisories for available updates
  2. --securitysecurity only
  • #rhel
  • #security-updates

Also known as: RHSA · RLSA · ELSA · security advisories

RHEL / AL2023: Check for a newer AL2023 release

Safe

AL2023 only. Its repos are locked to one release. Newer kernels and fixes often only come with a newer release.

sudo dnf check-release-update
What each part does
  1. dnf check-release-updatelist newer AL2023 releases (prints nothing if current)
  • #rhel
  • #packages

Also known as: releasever · new release available · al2023 release

RHEL / AL2023: Apply all updates

Caution

Installs every pending update including a new kernel.

Dry run first
sudo dnf upgrade --assumeno
sudo dnf upgrade -y
What each part does
  1. dnf upgradeupgrade all packages
  2. -yanswer yes
  • #rhel
  • #packages
  • #kernel

Also known as: update everything · patch vm · full update

RHEL / AL2023: Move AL2023 to the latest release

Caution

AL2023 only. Upgrades every package from the newest AL2023 release, including the kernel. Clears the most scanner findings.

Dry run first
sudo dnf upgrade --releasever=latest --assumeno
sudo dnf upgrade --releasever=latest -y
What each part does
  1. dnf upgradeupgrade packages
  2. --releasever=latestuse the newest release repo, not the locked one
  3. -yanswer yes

My note Stay on the current release: sudo dnf upgrade -y

  • #rhel
  • #packages
  • #kernel

Also known as: update everything · patch vm · full update · releasever latest

RHEL / AL2023: Apply security updates only

Caution

Installs only updates with a security advisory.

Dry run first
sudo dnf upgrade --security --assumeno
sudo dnf upgrade --security -y
What each part does
  1. --securityonly packages with a security advisory

My note Smallest possible change: sudo dnf upgrade-minimal --security

  • #rhel
  • #security-updates

Also known as: security only · security patch

RHEL / AL2023: Fix one advisory

Caution

Install only the packages from one advisory.

Dry run first
sudo dnf upgrade --advisory=<advisory-id> --assumeno
sudo dnf upgrade --advisory=<advisory-id>
What each part does
  1. --advisory=<advisory-id>e.g. RHSA-2026:19216 or RLSA-2026:89742
  • #rhel
  • #cve

Also known as: RHSA · RLSA · apply advisory

RHEL / AL2023: Fix one CVE

Caution

Install only the update that fixes one CVE.

Dry run first
sudo dnf upgrade --cve <CVE-ID> --assumeno
sudo dnf upgrade --cve <CVE-ID>
What each part does
  1. --cve <CVE-ID>packages whose advisory lists this CVE

My note See the advisory first: dnf updateinfo info --cve <CVE-ID>

  • #rhel
  • #cve

Also known as: fix cve · patch cve

RHEL / AL2023: Update the kernel

Caution

Installs the newest kernel next to the current one. The new kernel is used after a reboot.

Dry run first
sudo dnf upgrade 'kernel*' --assumeno
sudo dnf upgrade 'kernel*' -y
What each part does
  1. dnf upgrade 'kernel*'every installed kernel package: kernel on RHEL, kernel6.1 / kernel6.12 on AL2023 (quoted so the shell does not expand *)

My note Oracle Linux with UEK: sudo dnf upgrade kernel-uek -y. AL2023 not getting the "Fixed In" version? It may need a newer release: sudo dnf upgrade --releasever=latest

  • #rhel
  • #kernel

Also known as: kernel update · upgrade kernel · kernel6.12 · kernel-uek

RHEL / AL2023: Upgrade one package

Caution

Upgrade a single package (and only what it needs).

Dry run first
sudo dnf upgrade <package> --assumeno
sudo dnf upgrade <package>
What each part does
  1. dnf upgrade <package>e.g. python3-libs
  • #rhel
  • #packages

Also known as: single package · update one package

RHEL / AL2023: Install an exact package version

Caution

Install the exact "Fixed In" version from the scanner report.

Dry run first
sudo dnf install <package>-<version> --assumeno
sudo dnf install <package>-<version>
What each part does
  1. <package>-<version>list versions with dnf list --showduplicates <package>

My note Go back: sudo dnf downgrade <package>-<version>

  • #rhel
  • #packages

Also known as: specific version · fixed in version · downgrade

RHEL / AL2023: Lock a package version

Safe

Keep dnf upgrade from changing a package.

sudo dnf versionlock add <package>
What each part does
  1. dnf versionlock addlock the installed version (package python3-dnf-plugin-versionlock)

My note List: dnf versionlock list. Remove: sudo dnf versionlock delete <package>

  • #rhel
  • #packages

Also known as: freeze package · versionlock

RHEL / AL2023: Check if a reboot is needed

Safe

Exit code 1 and the reason when a reboot is needed.

sudo dnf needs-restarting -r
What each part does
  1. dnf needs-restarting -ris a reboot needed? (package dnf-utils)

My note Then: sudo reboot

  • #rhel
  • #reboot

Also known as: reboot required · needs-restarting

RHEL / AL2023: Confirm the new kernel after reboot

Safe

The running kernel should be the newest installed one.

uname -r && rpm -qa 'kernel*' | sort
What each part does
  1. uname -rrunning kernel
  2. rpm -qa 'kernel*'installed kernel packages (matches kernel on RHEL and kernel6.1 / kernel6.12 on AL2023)
  • #rhel
  • #kernel

Also known as: verify kernel · installed kernels

RHEL / AL2023: Set the default boot kernel

Caution

Choose which installed kernel boots next, e.g. go back to the previous one after a bad update.

Dry run first
sudo grubby --info /boot/vmlinuz-<version>
sudo grubby --set-default /boot/vmlinuz-<version>
What each part does
  1. grubby --set-defaultchange the default boot entry
  2. /boot/vmlinuz-<version>list them with ls /boot/vmlinuz-*

My note Current default: sudo grubby --default-kernel

  • #rhel
  • #kernel

Also known as: default kernel · kernel rollback · grubby

RHEL / AL2023: Remove old kernels

Caution

Keeps the two newest kernels and removes the rest (never the running one).

Dry run first
sudo dnf remove --oldinstallonly --setopt installonly_limit=2 --assumeno
sudo dnf remove --oldinstallonly --setopt installonly_limit=2 -y
What each part does
  1. --oldinstallonlyold versions of install-only packages (kernels)
  2. --setopt installonly_limit=2how many to keep
  • #rhel
  • #kernel

Also known as: old kernels · /boot full

RHEL / AL2023: Check a package changelog for a CVE fix

Safe

Red Hat backports fixes, so the version can look old. A match means the fix is in.

rpm -q --changelog <package> | grep -i <CVE-ID>
What each part does
  1. rpm -q --changelog <package>changelog of the installed package
  2. grep -i <CVE-ID>any match = fixed
  • #rhel
  • #cve

Also known as: verify cve fixed · backport

RHEL / AL2023: Undo the last update

Caution

Roll back the most recent dnf transaction.

Dry run first
sudo dnf history info last
sudo dnf history undo last
What each part does
  1. dnf historylist transactions
  2. undo lastrevert the newest one
  • #rhel
  • #packages

Also known as: rollback update · dnf history

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…