Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 79Security · Linux

How to patch a server with security updates

Most break-ins use known holes that already have a fix — the server just was not updated. Patching is routine work: see which security updates are open, install them in a planned window, restart what needs it (sometimes the whole server for a new kernel), and automate the boring part. This how-to does it on RHEL and Ubuntu.

  • 5 Lessen
  • 7 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

79.1

The quick answer

RHEL, Rocky, Alma:

dnf updateinfo list --security
dnf -y upgrade --security
dnf needs-restarting -r

Ubuntu, Debian:

apt-get update
apt list --upgradable
apt-get -y upgrade
ls /var/run/reboot-required 2>/dev/null && echo "reboot needed"

79.2

Step by step

  1. See what is open — security updates and their severity:
dnf updateinfo summary
dnf updateinfo list --security --sec-severity=Critical
dnf updateinfo info RHSA-2026:1234

On Ubuntu, apt list --upgradable lists all updates; the ones from the -security pocket are the security fixes.

  1. Plan it: test on a staging server first, take a snapshot or backup of important servers, tell the users, and set a silence in monitoring for the window.
  2. Install:
dnf -y upgrade --security
dnf -y upgrade
apt-get -y upgrade

--security = only security fixes (smallest change); a full upgrade brings everything (also bug fixes and new minor versions).

  1. Restart what needs it:
dnf needs-restarting -r
Reboot is required to fully utilize these updates.
dnf needs-restarting -s
systemctl restart nginx

-r = is a reboot needed (kernel, glibc, systemd)? -s = which services use old libraries. On Ubuntu, needrestart does this after apt.

  1. Reboot cleanly (when needed) and check the new kernel:
systemctl reboot
uname -r
  1. Automate security updates — at least on simple servers:
/etc/dnf/automatic.conf (part)
[commands]
upgrade_type = security
apply_updates = yes
dnf -y install dnf-automatic
systemctl enable --now dnf-automatic.timer
apt-get install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades

Reboots stay a planned decision (or a scheduled window). For many servers use Ansible, Satellite/Landscape, or the cloud's patch manager.

79.3

Check that it worked

dnf updateinfo list --security
dnf needs-restarting -r
No core libraries or services have been updated since boot-up.

No open security updates, no reboot pending, and the services work.

Commando's in deze les

79.4

Common problems

ProblemCauseFix
dnf updateinfo shows nothing on Rocky/Alma for a long timeErrata info depends on the repo.Check repos are enabled; compare with the vendor's advisories.
This system is not registered (RHEL)No subscription → no updates.rhc connect / subscription-manager register.
Service broke after the updateA new version changed behaviour.dnf history undo ID / reinstall the old version; test on staging next time.
Kernel updated, still old uname -rNo reboot yet.Reboot in the window (or live patching for urgent kernel CVEs).
apt held packagesDependencies or pinned versions.apt-mark showhold; plan the change.
Disk full during update/var or /boot full.Clean old kernels (dnf remove --oldinstallonly), free /var/cache.

79.5

Go further

1Which command shows if a reboot is needed after updates on RHEL?
2What is the difference between dnf upgrade --security and dnf upgrade?

The first installs only security fixes; the second installs all available updates.

Alle commando's in dit hoofdstuk