> ## Content Index
> Fetch the complete content index at: https://stackurity.ai/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to update OS packages on Debian and RHEL safely
- URL: https://stackurity.ai/blog/how-to-update-os-packages-on-debian-and-rhel-safely/
- Published: 2026-11-29T07:05:03.000Z
- Updated: 2026-11-29T07:05:03.000Z
- Description: Update OS packages on Debian and RHEL without an outage: conservative upgrades, security-only updates, restart checks and how to confirm the fix landed.
- Author: Stackurity Research Team
- Tags: Linux Servers, #how-to

## TL;DR

- Goal: apply operating system package updates on Debian and Red Hat style servers without breaking a service, and prove the fix landed.
- On Debian, refresh the package lists with `apt-get update`, then use the upgrade subcommand for a conservative update or `apt-get dist-upgrade` when dependencies must change.
- On RHEL, list the security advisories with `yum updateinfo list --security`, then apply them with `yum update --security`.
- After the update, check what must restart: `dnf needs-restarting` on dnf systems.
- Version numbers lie on both families because of backporting, so confirm the fix by advisory, not by upstream version.

## Why it matters

Most attacks on servers use flaws that already have a fix. The gap is rarely a missing patch in the vendor repository. It is a server nobody updated, or an update applied but never restarted, so the old code keeps running in memory. Updating safely means two things at once: closing the hole, and not causing an outage that makes the team afraid to patch next time.

A good routine is boring. You read what will change, apply it on one machine first, restart only what needs it, and check the result. This guide walks that routine on Debian and on Red Hat Enterprise Linux (RHEL), using commands from the official documentation. If you manage a mixed fleet, our [comparison of Vuls and Stackurity for Linux servers](https://stackurity.ai/compare/vuls) explains why a live inventory beats a spreadsheet for knowing which machines are on which release.

Recent examples show the pattern. Our post on [Ubuntu's five nginx fixes](https://stackurity.ai/blog/nginx-usn-8955-1-five-vulnerabilities/) is a case where the distribution shipped a fix inside an older version number, which is exactly the situation the backporting notes below explain.

## Before you start

- Root or sudo access on the server, and a console or out-of-band access in case a restart goes wrong.
- A maintenance window for anything customer facing, or a second node you can drain first.
- A snapshot or backup of the machine, and a test machine on the same release if you have one.
- A note of the services that must stay up, so you know what to check afterwards.

## Step by step

1. **Read the current state.** On Debian, run `apt-get update` so the package lists are fresh. The apt-get manual states that an update must come before an upgrade, otherwise apt-get does not know new versions exist. On RHEL, list what is pending with `yum updateinfo list --security`.
2. **Choose the conservative update first.** On Debian, the upgrade subcommand installs newer versions of what you already have, and never removes a package or installs a new one. Packages that would need that are held back at their current version. Use `apt-get dist-upgrade` only when you accept that it may change dependencies, and read the proposed changes before you agree.
3. **Apply security fixes only, when you cannot take everything.** On RHEL, `yum update --security` installs the security advisories without the feature and bugfix updates in the same repositories. The Red Hat solution article also documents a form that targets one CVE with the `--cve` option, which is useful when one flaw is urgent. The DNF command reference documents the same `--security` option for systems that use dnf.
4. **Update one machine, then wait.** Apply the update to the test machine or to one node, run the service health checks you wrote down, and give it time. Only then roll it to the rest, in small groups.
5. **Find what still runs old code.** A package update replaces files on disk, but a running process keeps the old library in memory. On dnf systems run `dnf needs-restarting`. Its `--reboothint` option tells you whether a reboot is advised, and its `--services` option lists services you can restart instead.
6. **Restart in order.** Restart the listed services first, drain and reboot the machine only if the hint says so, and bring the node back before you touch the next one.

## Why version numbers can mislead after an update

Red Hat describes backporting as taking a fix from the newest upstream version of a package and applying it to the older version it distributes. Debian handles security fixes in a similar way for its stable release. The result is that a package can carry a fix while its upstream version number looks old. A scanner or a person who compares only the upstream version will raise a false alarm, and may push an unneeded upgrade that breaks compatibility.

The safe habit is to read the vendor advisory for the package and the build number it names, and to compare against the installed build. The apt-get manual also documents `--only-upgrade`, which upgrades a named package only if it is already installed, a useful guard when you want a single fix and nothing else.

## How to confirm it worked

1. Run `yum updateinfo list --security` again on RHEL. The advisory you applied should no longer be listed as pending.
2. On Debian, run `apt-get update` and the upgrade subcommand again in simulation mode through your normal tooling. It should report that nothing is left to upgrade for that package.
3. Run `dnf needs-restarting` and confirm the list is empty or that you have restarted every entry.
4. Check the service itself: its health endpoint, its logs and a real request, not only that the process is running.

Doing this on one server is fine. Doing it across fifty servers, three images and a set of repositories is where it falls apart, which is the next section.

## How Stackurity helps

Stackurity keeps one live inventory of the packages on your servers, matches it against new advisories every hour, and gives each team a short list of upgrades, most urgent first. For Debian and RHEL it uses each distribution's own version rules, so a backported fix is not reported as a false alarm. Hosts that need a reboot or a restart after an update are flagged, so the half-finished update described above stays visible instead of silent.

![Fixes tab of the Ubuntu 20.04 server pos-api-1.northwind.example with one fix, Install available security updates, marked P1, SOS and known exploited, with the apt upgrade command.](https://stackurity.ai/blog/content/images/2026/11/stackurity-os-packages-1.webp)

Ubuntu security updates on one server as a single fix: every affected package, the known-exploited ones flagged, and the one command that installs them.

![Server page for db-1.northwind.example with a Reboot pending notice: the host runs older code than is installed.](https://stackurity.ai/blog/content/images/2026/11/stackurity-reboot-kernel-1.webp)

Patched is not the same as protected: this server installed a new kernel but still runs the old one, so its updates only take effect after a reboot.

After you apply a fix, Stackurity checks again and records whether the issue is really gone. See how the [remediation workflow](https://stackurity.ai/docs/remediation) orders upgrades and tracks the result.

[Start a free Stackurity trial](https://app.stackurity.dev/signup?utm%5Fsource=blog&utm%5Fmedium=referral&utm%5Fcampaign=linux-servers&utm%5Fcontent=how-to-update-os-packages-on-debian-and-rhel-safely) and see which of your servers still carry pending updates.

## FAQ

### Is apt-get upgrade the same as dist-upgrade?

No. The upgrade subcommand never removes an installed package and never installs a new one, so a package that needs a changed dependency stays at its old version. The dist-upgrade subcommand also handles those changing dependencies, which means it may add or remove packages.

### Does a RHEL package with an old version number still have the fix?

Often yes. Red Hat backports a security fix into the older version it ships instead of moving to a new upstream release, so the version number can look old while the flaw is gone. Check the advisory for the package, not the upstream version.

### How do I install only security updates on RHEL?

Run yum updateinfo list --security to see them, then yum update --security to apply them. On a system that uses dnf, the dnf command reference documents the same --security option.

### How do I know whether a server needs a reboot after updating?

On a dnf system, dnf needs-restarting reports what still runs old code, and its --reboothint option tells you whether a reboot is advised. On Debian, look at what the update installed before you decide.

### Can I roll back a bad update?

On dnf systems, the history command can undo a transaction, so note the transaction before you start. On Debian, keep the previous package versions available and test on one machine first, because a package manager cannot always step back cleanly.

## Sources

Sources: [apt-get manual (Debian manpages)](https://manpages.debian.org/bookworm/apt/apt-get.8.en.html), [Debian FAQ on keeping up to date](https://www.debian.org/doc/manuals/debian-faq/uptodate.en.html), [Red Hat on backporting security fixes](https://access.redhat.com/security/updates/backporting), [Red Hat on security-only updates](https://access.redhat.com/solutions/10021), [DNF needs-restarting](https://dnf-plugins-core.readthedocs.io/en/latest/needs%5Frestarting.html) and [DNF command reference](https://dnf.readthedocs.io/en/latest/command%5Fref.html).