Skip to content
VDS · Security

Automatic security updates

How to configure unattended-upgrades on Debian and Ubuntu and dnf-automatic on AlmaLinux so patches install themselves without the service going down at night.

Updated August 23, 2026

Most breaches come through vulnerabilities that were patched months ago. Manual updates get postponed; automatic ones don't. A sensible setup installs only security updates and leaves everything else alone.

Debian and Ubuntu

apt install -y unattended-upgrades apt-listchanges
dpkg-reconfigure -plow unattended-upgrades

The file /etc/apt/apt.conf.d/50unattended-upgrades:

Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::Package-Blacklist {
    "postgresql-.*";
    "docker-ce";
};
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Mail "you@example.com";

The schedule lives in /etc/apt/apt.conf.d/20auto-upgrades:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

A dry run, without making changes:

unattended-upgrade --dry-run --debug
systemctl status unattended-upgrades
cat /var/log/unattended-upgrades/unattended-upgrades.log

AlmaLinux and CentOS Stream

dnf install -y dnf-automatic

In /etc/dnf/automatic.conf:

[commands]
upgrade_type = security
apply_updates = yes
reboot = never
systemctl enable --now dnf-automatic.timer
systemctl list-timers | grep dnf

What to exclude

Add everything that breaks when its version changes unexpectedly to the exclusion list: the database server, Docker, the application engine itself. Update them by hand at a quiet time — see system and package updates.

Kernel security updates are installed too, but they only take effect after a reboot:

test -f /var/run/reboot-required && cat /var/run/reboot-required.pkgs

Rebooting: a human decision only

The temptation to set Automatic-Reboot "true" is strong, but an automatic nightly reboot means the service restarts with no one watching. If something doesn't come back up, you'll hear about it in the morning from your users.

A sensible compromise: updates install themselves, and you reboot manually once a month while watching the console in the /hosting/vds/m/<id> panel. While you're at it, check that the services start on their own:

systemctl is-enabled nginx postgresql
systemctl list-units --state=failed

Common mistakes

MistakeConsequenceFix
Enabled updates for all repositories, not just securityFeature changes arriveKeep only the -security source
The database isn't on the exclusion listA major version breaks the dataAdd it to Package-Blacklist
Automatic reboot at nightThe service didn't come up and no one noticedAutomatic-Reboot "false"
Set it up and forgot about itThe kernel updates but the update isn't appliedCheck reboot-required once a month
Downloaded packages filled the diskYou run out of spaceKeep automatic cache cleanup enabled

Automatic updates are insurance, not a replacement for attention. Once a month, open the machine, look at the update log, the list of failed services and whether a reboot is needed. Fifteen minutes a month covers most of the scenarios from the signs of a breach article.